许多不同的物种间都具有同源性。现代分子生物学中的同源性描述的是基因与基因之间相似关系,它表明的是两个相比较的序列之间的匹配程度。一般来说,如果两条基因序列相似性达80% ,就可以把它们称为“同源基因(homologousgene)”。
下载地址
# http://bioinf.wehi.edu.au/software/MSigDB/human_H_v5p2.rdata
# http://bioinf.wehi.edu.au/software/MSigDB/mouse_H_v5p2.rdata
#检查是否安装相应的R包
if (!requireNamespace(c("BiocManager",""), quietly = TRUE)){install.packages("BiocManager")}
if (!requireNamespace("clusterProfiler", quietly = TRUE)){BiocManager::install("clusterProfiler")}
if (!requireNamespace("org.Hs.eg.db", quietly = TRUE)){BiocManager::install("org.Hs.eg.db")}
if (!requireNamespace("org.Mm.eg.db", quietly = TRUE)){BiocManager::install("org.Mm.eg.db")}
if (!requireNamespace("homologene", quietly = TRUE)){install.packages("homologene")}
#加载相应的数据
load("human_H_v5p2.rdata")
load("mouse_H_v5p2.rdata")
#加载R包
library(clusterProfiler)
library(org.Hs.eg.db)
library(org.Mm.eg.db)
library(homologene)
human <- lapply(Hs.H, function(x){bitr(x, fromType = "ENTREZID", toType = "SYMBOL", OrgDb = org.Hs.eg.db)[,2]
})
mouse <- lapply(Mm.H, function(x){bitr(x, fromType = "ENTREZID",toType = "SYMBOL",OrgDb = org.Mm.eg.db)[,2]})
human_2_mouse <- sapply(names(human), function(x){homologene(human[[x]], inTax = 9606, outTax = 10116)[2]})
names(human_2_mouse) = sub("(.*?)\\.\\d+", "\\1", names(human_2_mouse),perl=TRUE)#重命名
human_length = sapply(names(human),function(x){length(human[[x]])})
mouse_length = sapply(names(mouse),function(x){length(mouse[[x]])})
human_only = sapply(names(human), function(x){length(setdiff(human_2_mouse[[x]],mouse[[x]]))})
mouse_only = sapply(names(human), function(x){length(setdiff(mouse[[x]],human_2_mouse[[x]]))})
intersect_human_mouse = sapply(names(human), function(x){length(intersect(human_2_mouse[[x]],mouse[[x]]))})
result = data.frame(human_genes=human_length,mouse_genes=mouse_length,overlap=intersect_human_mouse,human_specific=human_only,mouse_specific=mouse_only)
arrange <- function(data, start=1, end=length(data)){
if(start == end){
print(data)
}else{
i = start
for (number in start:end) {
mid=data[number];data[number]=data[i];data[i]=mid #i和number元素的位置互换
arrange(data, start + 1, end)
#如果前面n中元素位置发生了互换,那这个可以保证又换回来
mid=data[number];data[number]=data[i];data[i]=mid
}
}
}
arrange(1:3)
#arrange(1:9)
参考
https://www.sohu.com/a/258367748_777125
https://mp.weixin.qq.com/s/DgF0v1vQj65BPCvAFfZjQw
https://www.cnblogs.com/sunriseblogs/p/9873013.html