paul15数据集scanpy和Seurat可视化

python

import scanpy as sc
adata=sc.datasets.paul15()

sc.pp.normalize_per_cell(adata,counts_per_cell_after=1e4)# 这一部也是需要加入进去的。
sc.pp.filter_genes(adata,min_cells=1)
sc.pp.filter_genes_dispersion(adata,n_top_genes =2000) #top 1000 gene
#log1p data
sc.pp.log1p(adata)

sc.pp.scale(adata)

sc.pp.neighbors(adata)
sc.tl.umap(adata)
sc.pl.umap(adata,color=["paul15_clusters"])

最终的结果如图这里我发现一个问题,如果不是看保存成png的图,这个图的图例是少了了,其实并不是少了,是因为右边没有显示出来,图片显示太小
真正的结果如下
paul15数据集scanpy和Seurat可视化_第1张图片

R

rm(list=ls())
suppressPackageStartupMessages({
    library(SingleCellExperiment)
    library(Seurat)
})
paul=readRDS("./paul.rds")
# 这个数据是sc.datasets.pual15()是一样的,只不过是数据的信息
print("======paul信息=========")
print(paul)
## create Seurat object
paul <- CreateSeuratObject(assay(paul,"X"),meta.data = as.data.frame(colData(paul)),row.names = rownames(paul))
# meta.data不使用as.data.frame就会发生下面的错误
#Error in h(simpleError(msg, call)): 在为'['函数选择方法时评估'i'参数出了错: 在为'duplicated'函数选择方法时评估'x'参数出了错: DataFrame object with NULL colnames, please fix it with colnames(x) <- value  
#Traceback:

## Normalize the count data present in a given assay.
paul <- NormalizeData(object = paul)

## Identifies features that are outliers on a 'mean variability plot'.
paul <- FindVariableFeatures(object = paul)

## Scales and centers features in the dataset. If variables are provided in vars.to.regress, they are individually regressed against each feautre, and the resulting residuals are then scaled and centered.
paul <- ScaleData(
  object = paul
)

## Run a PCA dimensionality reduction. For details about stored PCA calculation parameters, see PrintPCAParams.
paul <- RunPCA(
  object = paul,
  pc.genes = paul@var.genes,verbose=F)
#runPCA和RunUMAP是同时等价地位的。
paul <- RunUMAP(paul, reduction = "pca", dims = 1:50,verbose = F)
DimPlot(paul, reduction = "umap", group.by = "paul15_clusters",label.size =10 )

结果如下
paul15数据集scanpy和Seurat可视化_第2张图片

你可能感兴趣的:(可视化,r语言,python)