# mirna和mrna互相预测
# BiocManager::install("multiMiR")
library(multiMiR)
# 开始计算,全程联网,mirna,target决定预测方向,空值时作为目标
example3 <- get_multimir(org = "hsa",
mirna = "hsa-miR-xxx-5p", # 你的miRNA
# target = "XXXX", # 你的mRNA
table = "predicted",
predicted.cutoff = 35,
predicted.cutoff.type = "p",
predicted.site = "all")
# 提取结果
example3_result <- example3@data
example3_result
# 查看各个数据库结果数
example3@data$database %>% table()
# 画图
library(VennDiagram)
library(tidyverse)
db <- unique(example3_result$database)
db
# 代码优化-------------------------------------------
# 1、每个数据库得结果分开,放入一个list
res_single_db <- db %>% lapply(function(x){example3_result %>% filter(database == x)})
names(res_single_db) <- db
res_single_db
# 2、每个数据库的预测目标分开,生成一个list
to_venn <- res_single_db %>% lapply(function(x){
unique(x$target_symbol)
})
names(to_venn) <- db
to_venn
# 3、提取想要使用的目标向量,此步不能省略
venn_list <-list(
diana_microt = to_venn$diana_microt,
elmmo = to_venn$elmmo,
# microcosm = to_venn$microcosm,
miranda = to_venn$miranda,
# mirdb = to_venn$mirdb,
# pictar = to_venn$pictar,
pita = to_venn$pita,
targetscan = to_venn$targetscan
)
# 4、画图,不能每个库的结果都用,可能没有结果
veenplot1 <- venn.diagram(
x = veen_list,
filename = ".\\plots\\venn1.pdf",
# disable.logging = TRUE,
ext.text = TRUE,
ext.line.lwd = 2,
ext.dist = -0.15,
ext.length = 0.9,
ext.pos = -4,
# inverted = TRUE,
cex = 1,
cat.cex = 1,
# rotation.degree = 45,
main = "Complex Venn Diagram",
# sub = "Featuring: rotation and external lines",
main.cex = 1,
sub.cex = 0.9
)
# 5、用循环求交集,代码来自知乎,解螺旋
for (i in 1:length(veen_list)){
if(i==1){
intergenes <- veen_list[[1]]
}
else{
intergenes <- intersect(intergenes,veen_list[[i]])
}
}
# 查看结果
intergenes
网友评论