美文网首页
Metaneighbor - 探究不同研究中的细胞亚类的相关性

Metaneighbor - 探究不同研究中的细胞亚类的相关性

作者: 重拾生活信心 | 来源:发表于2024-04-24 10:33 被阅读0次

MetaNeighbor/Documentation.md at master · gillislab/MetaNeighbor · GitHub

input & output
#BiocManager::install("MetaNeighbor")
# https://github.com/gillislab/MetaNeighbor/blob/master/Documentation.md

library(MetaNeighbor)
library(SummarizedExperiment)
data(mn_data)
  head(mn_data@colData)
  table(mn_data$study_id,mn_data$cell_type)
# sample_id {~ single cell}    study_id   cell_type
# 探究不同研究中的细胞亚类的相关性 【group by study_id+cell_type】
data(GOmouse)

# 
# Part 1: Supervised MetaNeighbor

AUROC_scores = MetaNeighbor(dat = mn_data,
                            experiment_labels = as.numeric(factor(mn_data$study_id)),
                            celltype_labels = metadata(colData(mn_data))[["cell_labels"]],
                            genesets = GOmouse,
                            bplot = TRUE)
head(AUROC_scores)

# Part 2: MetaNeighbor for Data Exploration

# library(MetaNeighbor)
# data(mn_data)
var_genes = variableGenes(dat = mn_data, exp_labels = mn_data$study_id)
length(var_genes)
head(var_genes)
celltype_NV = MetaNeighborUS(var_genes = var_genes,
                             dat = mn_data,
                             study_id = mn_data$study_id,
                             cell_type = mn_data$cell_type)
top_hits = topHits(cell_NV = celltype_NV,
                   dat = mn_data,
                   study_id = mn_data$study_id,
                   cell_type = mn_data$cell_type,
                   threshold = 0.9)
top_hits
cols = rev(colorRampPalette(RColorBrewer::brewer.pal(11,"RdYlBu"))(100))
breaks = seq(0, 1, length=101)
gplots::heatmap.2(celltype_NV,
                  margins=c(8,8),
                  keysize=1,
                  key.xlab="AUROC",
                  key.title="NULL",
                  trace = "none",
                  density.info = "none",
                  col = cols,
                  breaks = breaks,
                  offsetRow=0.1,
                  offsetCol=0.1,
                  cexRow = 0.7,
                  cexCol = 0.7)
## Run MetaNeighbor for data exploration
# Once we have a set of highly variable genes, we can simply run an exploratory version of MetaNeighbor using the function:


celltype_NV = MetaNeighborUS(var_genes = var_genes,
                             dat = mn_data,
                             study_id = mn_data$study_id,
                             cell_type = mn_data$cell_type)

cols = rev(colorRampPalette(RColorBrewer::brewer.pal(11,"RdYlBu"))(100))
breaks = seq(0, 1, length=101)
gplots::heatmap.2(celltype_NV,
                  margins=c(8,8),
                  keysize=1,
                  key.xlab="AUROC",
                  key.title="NULL",
                  trace = "none",
                  density.info = "none",
                  col = cols,
                  breaks = breaks,
                  offsetRow=0.1,
                  offsetCol=0.1,
                  cexRow = 0.7,
                  cexCol = 0.7)

#Identify reciprocal top hits and high scoring cell type pairs
top_hits = topHits(cell_NV = celltype_NV,
                   dat = mn_data,
                   study_id = mn_data$study_id,
                   cell_type = mn_data$cell_type,
                   threshold = 0.9)
top_hits

相关文章

网友评论

      本文标题:Metaneighbor - 探究不同研究中的细胞亚类的相关性

      本文链接:https://www.haomeiwen.com/subject/akfgxjtx.html