R match
#Gene mice -> human human = useMart("ensembl",dataset = "hsapiens_gene_ensembl") mouse = useMart("ensembl",dataset = "mmusculus_gene_ensembl") rowgene_h <- getLDS(attributes = c("mgi_symbol"),filters = "mgi_symbol",values = rownames(expr_all), mart = mouse,attributesL = c("hgnc_symbol","chromosome_name","start_position"), martL = human,uniqueRows = F) gl <- c() for(i in 1:length(keggSet)){ gl <- c(gl,keggSet[[i]]@geneIds) } gl <- unique(gl) #gsva_matrix <- as.matrix(expr_all@assays$RNA@data) rownames(gsva_matrix) <- rowgene_h$HGNC.symbol[match(rownames(gsva_matrix),rowgene_h$MGI.symbol)] gsva_matrix <-gsva_matrix[intersect(gl,rownames(gsva_matrix)),]
经常忘记怎么按照一定的顺序排列dataframe 其实一个match就解决了。。。。我再忘记我就去吃屎!