require(Momocs) require(gridExtra) lf1 <- list.files('C:/Users/Viktor Baranov/Documents/Baranov/my papers/in work/22.stratiomyomiomorpha larvae/masks stratiomyomorpha/new masks', full.names=TRUE) #path to files #coo <- import_jpg(lf)#import coo <- import_jpg(lf1)#import Out(coo)#conversion to outlines dat=Out(coo)# outlines saved as cash object panel(dat)#plotting outlines #stack(dat)#stacking the shapes together #dat %>% # coo_center %>% coo_scale %>% #coo_alignxax() %>% coo_slidedirection("right") %T>% #print() %>% stack() #centering and un-directioning stack b <- coo_rotate(dat[1], pi/6) # dummy example just to make it obvious coo_plot(b) coo_plot(coo_slidedirection(b, "up")) coo_plot(coo_slidedirection(b, "right")) coo_plot(coo_slidedirection(b, "left")) coo_plot(coo_slidedirection(b, "down")) b <- dat %>% slice(1:69) # for speed sake stack(b) dat %>% slice(1:69)%>% coo_center %>% coo_scale %>% coo_alignxax()%>% stack(b) #centering and un-directioning stack #dat.ld<- def_ldk(dat, 3, close = T, points = T) # define 3 landmarks #dat.ld <- def_ldk(dat, 4) dat.ld=dat dat.ld$fake <- factor(c("Xylophagous", "Xylophagous", "Xylophagous", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "Xylophagous", "aquatic", "terrestrial", "terrestrial", "terrestrial", "unknown", "terrestrial", "unknown", "aquatic", "aquatic", "aquatic", "terrestrial", "terrestrial", "unknown", "aquatic", "aquatic", "aquatic", "aquatic", "aquatic", "aquatic", "aquatic", "aquatic", "aquatic", "aquatic", "terrestrial", "terrestrial", "terrestrial", "unknown", "unknown", "unknown", "unknown", "terrestrial", "terrestrial", "terrestrial", "aquatic", "terrestrial", "terrestrial", "terrestrial", "terrestrial", "unknown", "terrestrial", "aquatic", "aquatic", "aquatic", "aquatic", "aquatic", "aquatic", "terrestrial", "unknown", "terrestrial", "unknown", "terrestrial", "terrestrial", "terrestrial", "terrestrial")) dat.ld$fake2 <- factor(c( "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "burmese", "extant", "messel", "extant", "extant", "extant", "extant", "extant", "burmese", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "baltic", "burmese", "burmese", "burmese", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "slovenian shales", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", " Limestone Montsech", "extant", "dominican", "extant", "extant", "extant", "extant")) #id of the fossils dat.ld$fake3 <- factor(c("extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "Liu et al. 2019 mt 1", "extant", "Messel specimen", "extant", "extant", "extant", "extant", "extant", "NHMLA spec 2", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "ped01", "ped0041", "ped0362", "ped0031", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "slovenian shales", "extant", "extant", "extant", "extant", "extant", "extant", "extant", "extant", " Limestone Montsech", "extant", "dominican", "extant", "extant", "extant", "extant")) coo_oscillo(dat.ld[1], "efourier") Ptolemy(dat.ld[1]) dat.f <- efourier(dat.ld) dat.f <- efourier(dat.ld, nb.h=36) dat.p <- PCA(dat.f) m=MANOVA(dat.p, dat.ld$fake) m <- manova(dat.p$x[, 1:69] ~ dat.ld$fake2) summary.aov(m) plot(dat.p) library(ggplot2) library(grid) library(gridExtra) library(ggfortify) df_out <- as.data.frame(dat.p$x) plot(dat.p, dat.ld$fake,chull=TRUE, ellipses=TRUE, conf_ellipses = 0.9) plot(dat.p, dat.ld$fake2,chull=TRUE, ellipses=TRUE, conf_ellipses = 0.9) plot(dat.p, dat.ld$fake3,chull=TRUE, ellipses=TRUE, conf_ellipses = 0.9) hist(dat.f, drop=0) boxplot(dat.f, drop=1) dat.p <- PCA(dat.f) class(dat.p) # a PCA object, let's plot it plot(dat.p) #coo_plot(coo_slidedirection(b, "up")) #coo_plot(coo_slidedirection(b, "right")) #coo_plot(coo_slidedirection(b, "left")) #coo_plot(coo_slidedirection(b, "down")) ading #(dat, title = "Non-aligned head") #dat.al <- fgProcrustes(dat, tol = 1e-4) %>% coo_slidedirection(b, "right") #stack(dat.al, title="Aligned heads") # plot(dat.p, dat$fake) plot(dat.p, dat.ld$fake, 1, pos.shp="circle", stars=TRUE, chull.filled=TRUE, palette=col_spring) PCcontrib(dat.p) dat.l <- LDA(dat.p,dat$fake) MANOVA_PW(dat.p, "fake") KMEANS(dat.p, centers = 10) dat.f %>% mshapes() %>% coo_plot() dat %>% efourier(norm=TRUE) %>% PCA() %>% plot("fake")