Momocs是一個
使用R進行表型變化
的軟體包,旨在從形狀中提取定量變數。下面就來看看Momocs是如何操作的:
操作步驟
首先,把要處理的圖片準備好
#FormatImgID_1#
將影象顏色降為8位
#FormatImgID_2#
然後調整threshold
#FormatImgID_3#
拖動使得紅色與要測量的形狀符合
#FormatImgID_4#
#FormatImgID_5#
形狀提取好了
#FormatImgID_6#
加入Erode
#FormatImgID_7#
加Dilate
#FormatImgID_8#
加入Gaussian Blur
#FormatImgID_9#
設定sigma值
#FormatImgID_10#
轉換好了
#FormatImgID_11#
#儲存為JPG格式
#FormatImgID_12#
#再儲存為text image格式
#FormatImgID_13#
install.packages("devtools")library(devtools)devtools::install_github("MomX/Momocs")library(Momocs)#獲取檔案列表lf <- list.files(full.names=TRUE, pattern = "jpg")#讀取jpg檔案coo <- import_jpg(lf)
install.packages("devtools")
library(devtools)devtools::install_github("MomX/Momocs")library(Momocs)#獲取檔案列表lf <- list.files(full.names=TRUE, pattern = "jpg")#讀取jpg檔案coo <- import_jpg(lf)
#編輯標籤
#FormatImgID_14#
#匯入標籤
label<-read.table("label.txt",head=T)
#把影象與標籤合併
cooo<-Out(coo, fac = label, ldk = list())
#只畫第一張圖
coo[1] %>% paper %>% draw_outline
#FormatImgID_15#
#畫所有的圖
coo %>% paper %>% draw_curve
#FormatImgID_16#
#改為透明背景
coo %>% paper_chess %>% draw_outline -> x
x
#FormatImgID_17#
#載入不同背景
apropos("paper")
#加顏色
paper(cooo) %>%draw_outlines(factor(rep(1:2, 1)), bor=col_qual) %>%draw_centroid(~type, pch=c(1, 3))
paper(cooo) %>%
draw_outlines(factor(rep(1:2, 1)), bor=col_qual) %>%
draw_centroid(~type, pch=c(1, 3))
#FormatImgID_18#
#畫出單個形狀
shp <- coo[1]coo_plot(shp)
shp <- coo[1]
coo_plot(shp)
#FormatImgID_19#
#填充顏色
coo_plot(shp, col="grey80", border=NA, centroid=FALSE, main="Meow")
#FormatImgID_20#
#描點
coo_plot(coo_sample(shp, 32), points=TRUE, pch=20, main="64-pts Meow")
#FormatImgID_21#
#平滑
shp %>% coo_smooth(5) %>% coo_sample(64) %>% coo_scale() %>% coo_plot()
#FormatImgID_22#
#座標軸轉換
cooo %>%coo_center %>% coo_scale %>%coo_alignxax() %>% coo_slidedirection("up") %T>%print() %>% stack()
cooo %>%
coo_center %>% coo_scale %>%
coo_alignxax() %>% coo_slidedirection("up") %T>%
print() %>% stack()
#FormatImgID_23#
#新增顏色
cooo %>% paper_grid %>%draw_outline(~type, bor=col_qual) %>%draw_axes %>% draw_centroid %>% draw_firstpoint
cooo %>% paper_grid %>%
draw_outline(~type, bor=col_qual) %>%
draw_axes %>% draw_centroid %>% draw_firstpoint
#FormatImgID_24#
#填充顏色
data(cooo)cooopanel(cooo, fac="type", names=TRUE)
data(cooo)
cooo
panel(cooo, fac="type", names=TRUE)
#FormatImgID_25#
#橢圓分析
coo_oscillo(cooo[1], "efourier")
#FormatImgID_26#
#托勒密分析
Ptolemy(cooo[1])
#FormatImgID_27#
#直方圖
bot.f <- efourier(cooo, nb.h=10)bot.fhist(bot.f, drop=0)
bot.f <- efourier(cooo, nb.h=10)
bot.f
hist(bot.f, drop=0)
#FormatImgID_28#
#箱線圖
boxplot(bot.f, drop=1)
#FormatImgID_29#
#主成分分析
bot.p <- PCA(bot.f)class(bot.p) # a PCA object, let's plot itplot(bot.p)
bot.p <- PCA(bot.f)
class(bot.p) # a PCA object, let's plot it
plot(bot.p)
#FormatImgID_30#
#填充顏色
panel(cooo, fac="type", names="type")
#FormatImgID_31#
#主成分分析
bot.p <- PCA(bot.f)plot(bot.p)plot(bot.p, 1, chull=TRUE, pos.shp = "full_axes", abbreviate.labelsgroups = TRUE, points=FALSE, labelspoints = TRUE)
bot.p <- PCA(bot.f)
plot(bot.p)
plot(bot.p, 1, chull=TRUE, pos.shp = "full_axes", abbreviate.labelsgroups = TRUE, points=FALSE, labelspoints = TRUE)
#FormatImgID_32#
#主成分分析比重
scree(bot.p)scree_plot(bot.p)
scree(bot.p)
scree_plot(bot.p)
#FormatImgID_33#
boxplot(bot.p, 1)
#FormatImgID_34#
PCcontrib(bot.p)
#FormatImgID_35#
下面,開始一個專案的分析
#清空R中資料
rm(list = ls())
#載入包
require(Momocs)
#規定輪廓的配位數,擬南芥一般為400-1000
pnt_num <- 500
想知道轉錄組測得怎麼樣?快來RSeQC一下
用guidance檢測序列比對準確率
生物軟體,會用這個就夠了!
快速檢索英文文獻?Web of knowledge瞭解一下
用Evolview美化系統發育樹,簡單又高階
使用Imaris對鐳射共聚焦照片進行體積測量及共定位分析
關注科研日精進Get更多科研小工具