/SlicerMorph_Rexamples

Some functions to import SlicerMorph data into R

Primary LanguageR

SlicerMorph_Rexamples

Some functions to import SlicerMorph data into R

  • read.markups.fcsv.R: utility function to read a FCSV formatted markups file into R as a matrix.
  • read.markups.json.R: utility function to read a JSON formatted markups file into R as a matrix.
  • geomorph_regression.Rmd: an example of import SlicerMorph GPA output to conduct allometric regression with SlicerMorph data. It also compares results SlicerMorph GPA results to the one derived from R/geomorph using the raw LM coordinates.
  • slide_semiLMs.Rmd: an example of importing SlicerMorph GPA output to slide semiLMs in R using geomorph.
  • bilat_symmetry.R: a simple R script that demonstrate how to symmetry analysis in R/geomorph using SlicerMorph output. It uses the log_parser.R function below to obtain necessary fields.
  • log_parser.R: Since ?/?/? SlicerMorph's GPA module outputs a log file that contains summary of settings used in the GPA analysis, including input/output folders, filenames, formats, number of landmarks, excluded (if any) landmarks, centroid size scaling, and the output files. This Rscript parses this log file and returns a named list with:
    • $input.path = Unix style path to input folder with landmark files.
    • $output.path = Unix stype path to the output folder created by GPA
    • $files = files included in the analysis
    • $format = format of landmark files ("fcsv" or "mrk.json")
    • $no.LM = number of landmarks original
    • $skipped = If any landmark is omitted in GPA (TRUE/FALSE)
    • $skippedLM = Indices of skipped LMs (created only if $skipped==TRUE)
    • $scale = are data scaled by centroid sizes (TRUE/FALSE)
    • $MeanShape = filename that contains mean shape coordinates calculated by GPA (csv format)
    • $eigenvalues = filename that contains eigenvalues as calculated by PCA in the SlicerMorph GPA (csv format)
    • $eigenvectors = filename that contains eigenvectors as calculated by PCA in the SlicerMorph GPA (csv format)
    • $OutputData = filename that contains procrustes distances, centroid sizes and procrustes aligned coordinates as calculated by the SlicerMorph GPA (csv format)
    • $pcScores = filename that contains individal PC scores of specimens as calculated by PCA in the SlicerMorph GPA (csv format)
    • $ID = list of specimen identifiers
    • $LM = 3D landmark array that contains the 3D raw coordinates as inputed to the SlicerMorph GPA module.
    • $semi = If any landmarks are tagged as semi-landmarks (TRUE/FALSE)
    • $semiLM = indices of LMs tagged as semi-landmarks (created only if $semi==TRUE)

Example for usage:

slicermorph.log = parser("C:/temp/RemoteIO/gorilla_patches/merged/2021-02-14_20_31_08/analysis.log")
slicermorph.log
$input.path
[1] "C:/temp/RemoteIO/gorilla_patches/merged"

$output.path
[1] "C:/temp/RemoteIO/gorilla_patches/merged/2021-04-05_20_51_17"

$files
[1] "USNM174715_LM_merged.mrk.json" "USNM174722_LM_merged.mrk.json" "USNM176209_LM_merged.mrk.json" "USNM176216_LM_merged.mrk.json"

$format
[1] ".mrk.json"

$no.LM
[1] 921

$skipped
[1] FALSE

$semi
[1] TRUE

$semiLMs
  [1] " 42" "43"  "44"  "45"  "46"  "47"  "48"  "49"  "50"  "51"  "52"  "53"  "54"  "55"  "56"  "57"  "58"  "59"  "60"  "61"  "62"  "63"  "64"  "65"  "66"  "67" 
 [27] "68"  "69"  "70"  "71"  "72"  "73"  "74"  "75"  "76"  "77"  "78"  "79"  "80"  "81"  "82"  "83"  "84"  "85"  "86"  "87"  "88"  "89"  "90"  "91"  "92"  "93" 
 [53] "94"  "95"  "96"  "97"  "98"  "99"  "100" "101" "102" "103" "104" "105" "106" "107" "108" "109" "110" "111" "112" "113" "114" "115" "116" "117" "118" "119"
 [79] "120" "121" "122" "123" "124" "125" "126" "127" "128" "129" "130" "131" "132" "133" "134" "135" "136" "137" "138" "139" "140" "141" "142" "143" "144" "145"
[105] "146" "147" "148" "149" "150" "151" "152" "153" "154" "155" "156" "157" "158" "159" "160" "161" "162" "163" "164" "165" "166" "167" "168" "169" "170" "171"
[131] "172" "173" "174" "175" "176" "177" "178" "179" "180" "181" "182" "183" "184" "185" "186" "187" "188" "189" "190" "191" "192" "193" "194" "195" "196" "197"
[157] "198" "199" "200" "201" "202" "203" "204" "205" "206" "207" "208" "209" "210" "211" "212" "213" "214" "215" "216" "217" "218" "219" "220" "221" "222" "223"
[183] "224" "225" "226" "227" "228" "229" "230" "231" "232" "233" "234" "235" "236" "237" "238" "239" "240" "241" "242" "243" "244" "245" "246" "247" "248" "249"
[209] "250" "251" "252" "253" "254" "255" "256" "257" "258" "259" "260" "261" "262" "263" "264" "265" "266" "267" "268" "269" "270" "271" "272" "273" "274" "275"
[235] "276" "277" "278" "279" "280" "281" "282" "283" "284" "285" "286" "287" "288" "289" "290" "291" "292" "293" "294" "295" "296" "297" "298" "299" "300" "301"
[261] "302" "303" "304" "305" "306" "307" "308" "309" "310" "311" "312" "313" "314" "315" "316" "317" "318" "319" "320" "321" "322" "323" "324" "325" "326" "327"
[287] "328" "329" "330" "331" "332" "333" "334" "335" "336" "337" "338" "339" "340" "341" "342" "343" "344" "345" "346" "347" "348" "349" "350" "351" "352" "353"
[313] "354" "355" "356" "357" "358" "359" "360" "361" "362" "363" "364" "365" "366" "367" "368" "369" "370" "371" "372" "373" "374" "375" "376" "377" "378" "379"
[339] "380" "381" "382" "383" "384" "385" "386" "387" "388" "389" "390" "391" "392" "393" "394" "395" "396" "397" "398" "399" "400" "401" "402" "403" "404" "405"
[365] "406" "407" "408" "409" "410" "411" "412" "413" "414" "415" "416" "417" "418" "419" "420" "421" "422" "423" "424" "425" "426" "427" "428" "429" "430" "431"
[391] "432" "433" "434" "435" "436" "437" "438" "439" "440" "441" "442" "443" "444" "445" "446" "447" "448" "449" "450" "451" "452" "453" "454" "455" "456" "457"
[417] "458" "459" "460" "461" "462" "463" "464" "465" "466" "467" "468" "469" "470" "471" "472" "473" "474" "475" "476" "477" "478" "479" "480" "481" "482" "483"
[443] "484" "485" "486" "487" "488" "489" "490" "491" "492" "493" "494" "495" "496" "497" "498" "499" "500" "501" "502" "503" "504" "505" "506" "507" "508" "509"
[469] "510" "511" "512" "513" "514" "515" "516" "517" "518" "519" "520" "521" "522" "523" "524" "525" "526" "527" "528" "529" "530" "531" "532" "533" "534" "535"
[495] "536" "537" "538" "539" "540" "541" "542" "543" "544" "545" "546" "547" "548" "549" "550" "551" "552" "553" "554" "555" "556" "557" "558" "559" "560" "561"
[521] "562" "563" "564" "565" "566" "567" "568" "569" "570" "571" "572" "573" "574" "575" "576" "577" "578" "579" "580" "581" "582" "583" "584" "585" "586" "587"
[547] "588" "589" "590" "591" "592" "593" "594" "595" "596" "597" "598" "599" "600" "601" "602" "603" "604" "605" "606" "607" "608" "609" "610" "611" "612" "613"
[573] "614" "615" "616" "617" "618" "619" "620" "621" "622" "623" "624" "625" "626" "627" "628" "629" "630" "631" "632" "633" "634" "635" "636" "637" "638" "639"
[599] "640" "641" "642" "643" "644" "645" "646" "647" "648" "649" "650" "651" "652" "653" "654" "655" "656" "657" "658" "659" "660" "661" "662" "663" "664" "665"
[625] "666" "667" "668" "669" "670" "671" "672" "673" "674" "675" "676" "677" "678" "679" "680" "681" "682" "683" "684" "685" "686" "687" "688" "689" "690" "691"
[651] "692" "693" "694" "695" "696" "697" "698" "699" "700" "701" "702" "703" "704" "705" "706" "707" "708" "709" "710" "711" "712" "713" "714" "715" "716" "717"
[677] "718" "719" "720" "721" "722" "723" "724" "725" "726" "727" "728" "729" "730" "731" "732" "733" "734" "735" "736" "737" "738" "739" "740" "741" "742" "743"
[703] "744" "745" "746" "747" "748" "749" "750" "751" "752" "753" "754" "755" "756" "757" "758" "759" "760" "761" "762" "763" "764" "765" "766" "767" "768" "769"
[729] "770" "771" "772" "773" "774" "775" "776" "777" "778" "779" "780" "781" "782" "783" "784" "785" "786" "787" "788" "789" "790" "791" "792" "793" "794" "795"
[755] "796" "797" "798" "799" "800" "801" "802" "803" "804" "805" "806" "807" "808" "809" "810" "811" "812" "813" "814" "815" "816" "817" "818" "819" "820" "821"
[781] "822" "823" "824" "825" "826" "827" "828" "829" "830" "831" "832" "833" "834" "835" "836" "837" "838" "839" "840" "841" "842" "843" "844" "845" "846" "847"
[807] "848" "849" "850" "851" "852" "853" "854" "855" "856" "857" "858" "859" "860" "861" "862" "863" "864" "865" "866" "867" "868" "869" "870" "871" "872" "873"
[833] "874" "875" "876" "877" "878" "879" "880" "881" "882" "883" "884" "885" "886" "887" "888" "889" "890" "891" "892" "893" "894" "895" "896" "897" "898" "899"
[859] "900" "901" "902" "903" "904" "905" "906" "907" "908" "909" "910" "911" "912" "913" "914" "915" "916" "917" "918" "919" "920" "921"

$scale
[1] TRUE

$MeanShape
[1] "MeanShape.csv"

$eigenvalues
[1] "eigenvalues.csv"

$eigenvectors
[1] "eigenvectors.csv"

$OutputData
[1] "OutputData.csv"

$pcScores
[1] "pcScores.csv"

$ID
[1] "USNM174715_LM_merged" "USNM174722_LM_merged" "USNM176209_LM_merged" "USNM176216_LM_merged"

$LM
, , USNM174715_LM_merged

             x         y          z
1   -109.17300 -330.2660 -145.48000
2   -114.15900 -396.1410 -128.71400
3   -110.47600 -302.8060  -87.92080
4   -108.71900 -276.1560 -106.79900
5   -107.35100 -270.1980 -118.94400
6   -105.20600 -247.3930 -160.39200
7   -104.62400 -217.0150 -161.95400
8   -115.18100 -248.3020 -163.41700
9    -96.27470 -250.1250 -162.11100
10  -123.91400 -228.3400 -163.64500
11   -84.58430 -231.1230 -164.44100
12  -124.58600 -246.6700 -150.83100
13   -86.96560 -249.5490 -151.22200
14  -134.27900 -240.9120 -153.56600
15   -77.84840 -245.8070 -155.51900
16  -146.68700 -241.9100 -147.58200
17   -63.74880 -247.7270 -149.09100
18  -109.10900 -317.1660  -49.05330
19  -113.02000 -370.4450  -81.87840
20  -114.57000 -393.8680 -110.42000
21  -115.84400 -423.4980 -113.17500
22  -147.43100 -308.1560  -44.41880
23   -74.25550 -307.9240  -44.05720
24  -167.68400 -305.5140  -62.67320
25   -52.67670 -309.8970  -64.37480
26  -120.20000 -319.3720  -68.03920
27   -98.45590 -319.9960  -69.01920
28  -133.13900 -335.7460  -81.58340
29   -88.64880 -338.1650  -81.65340
30  -189.86500 -319.5460  -97.29880
31   -31.01130 -325.2640  -97.55350
32  -175.70000 -349.7790 -119.93000
33   -48.89370 -354.9990 -119.70800
34  -145.42700 -359.6420  -95.92180
35   -80.53060 -362.3540  -94.77980
36  -133.86200 -388.8390  -99.33610
37   -94.84410 -390.3740  -99.00900
38  -133.22300 -422.5990 -115.62300
39   -98.29100 -424.5970 -114.33800
40  -149.15400 -398.0440 -137.46500
41   -78.33230 -401.6130 -135.32300
42  -132.22856 -342.4400  -82.87096
43  -130.02647 -346.1437  -83.18362
44  -127.67728 -350.5166  -82.26191
45  -125.36446 -354.7242  -81.64531
46  -123.09546 -358.7322  -81.39661
47  -120.81516 -362.7917  -81.05300
48  -118.59048 -366.5982  -81.17604
49  -133.55605 -345.2674  -84.14644
50  -131.30141 -349.2101  -84.01811
51  -128.94194 -353.6297  -83.01037
52  -126.66726 -357.6636  -82.71386
53  -124.44346 -361.4661  -82.84435
54  -122.19733 -365.3702  -82.78739
55  -134.85880 -348.2071  -85.21453
56  -132.58142 -352.2533  -84.89539
57  -130.27034 -356.4529  -84.29346
58  -128.02649 -360.3466  -84.25568
59  -125.80061 -364.1585  -84.36878
60  -136.12250 -351.3246  -85.95471
61  -133.86867 -355.2636  -85.83342
62  -131.63747 -359.0998  -85.90179
63  -129.36984 -363.1017  -85.66451
64  -137.41130 -354.3279  -86.90578
65  -135.22139 -357.9762  -87.32064
66  -133.00676 -361.7370  -87.52803
67  -138.75777 -357.0688  -88.34052
68  -136.59294 -360.6029  -88.96607
69  -140.12634 -359.7092  -89.96101
70  -129.48975 -337.8159  -80.07718
71  -126.79589 -341.0214  -80.76524
72  -124.85319 -345.2919  -80.37954
73  -123.00690 -349.6992  -79.85603
74  -120.97350 -353.8411  -79.59998
75  -119.08329 -358.1861  -79.13925
76  -117.01736 -362.2819  -78.92971
77  -127.79458 -335.6315  -78.94035
78  -125.15065 -338.9077  -79.55704
79  -123.19472 -343.1595  -79.19027
80  -121.19190 -347.3448  -78.89050
81  -119.34605 -351.7527  -78.36636
82  -117.41369 -356.0379  -77.96589
83  -126.19997 -333.5896  -77.65979
84  -123.49902 -336.7850  -78.35799
85  -121.53329 -341.0229  -78.00521
86  -119.56850 -345.2621  -77.65111
87  -117.66492 -349.5881  -77.20948
88  -124.72687 -331.7200  -76.20554
89  -121.98729 -334.8606  -76.95895
90  -119.98711 -339.0497  -76.65543
91  -117.98911 -343.2418  -76.34879
92  -123.24669 -329.8404  -74.76138
93  -120.58500 -333.0915  -75.40346
94  -118.60883 -337.3145  -75.06562
95  -121.82040 -328.0372  -73.24020
96  -119.16814 -331.3016  -73.86880
97  -120.45251 -326.3168  -71.63556
98  -102.49448 -325.8408  -70.22696
99  -104.09470 -330.1659  -72.12097
100 -105.72586 -336.6898  -73.21606
101 -107.34427 -342.3077  -74.64033
102 -108.97501 -348.8018  -75.74623
103 -110.59983 -354.8754  -77.00491
104 -112.22638 -361.0716  -78.21906
105 -104.92935 -327.1106  -69.63148
106 -106.55410 -333.1789  -70.89210
107 -108.16519 -338.2768  -72.50530
108 -109.78030 -343.6608  -74.01456
109 -111.39760 -349.1996  -75.46761
110 -113.01520 -354.7601  -76.91273
111 -107.38916 -330.1529  -68.39196
112 -108.99459 -334.8488  -70.15124
113 -110.59497 -339.1859  -72.04089
114 -112.19718 -343.6532  -73.88326
115 -113.80901 -348.8040  -75.47726
116 -109.83187 -331.9804  -67.59383
117 -111.42061 -335.4908  -69.78389
118 -113.00556 -338.7317  -72.07187
119 -114.59680 -342.4195  -74.19746
120 -112.24746 -331.8811  -67.49583
121 -113.81391 -333.8079  -70.26130
122 -115.39008 -336.4242  -72.77622
123 -114.62249 -328.9003  -68.44486
124 -116.19797 -331.4683  -70.97734
125 -116.99333 -325.6221  -69.50191
126  -99.54158 -326.7212  -72.60339
127 -101.62721 -331.5724  -74.66275
128 -103.13805 -337.3511  -75.94667
129 -104.40447 -343.5243  -76.90086
130 -105.61355 -349.7900  -77.77767

 [ reached getOption("max.print") -- omitted 588 row(s) and 3 matrix slice(s) ]