我试图获得我所做的函数的多个输出
ratio_marker_out_2 = function(marker_gene, cluster_id){
marker_gene = list(row.names(FindMarkers(glioblastoma, ident.1 = cluster_id)))
for (gene in marker_gene){
all_cells_all_markers = glioblastoma@assays$RNA@counts[gene,]
selected_cells_all_marker = all_cells_all_markers[cluster_id!=Idents(glioblastoma)]
gene_count_out_cluster = glioblastoma@assays$RNA@counts[,cluster_id!=Idents(glioblastoma)]
ratio_out = sum(selected_cells_all_marker)/sum(gene_count_out_cluster)
}
return(ratio_out)
}
这里,marker_gene 的长度大约是几百。假设长度为100。我想得到marker_gene中每个基因的ratio_out。然而,当运行这个函数时,我只得到一个输出而不是 100 个 ratio_out 的列表。可以请任何人帮助如何解决它?
我得到的输出
ratio_marker_out_2(marker_gene, 0)
是1 0.5354895。请看下图