scanpy.pl

API: Plotting

sc.pl.highest_expr_genes()

https://scanpy.readthedocs.io/en/stable/api/generated/scanpy.pl.highest_expr_genes.html#scanpy.pl.highest_expr_genes

Boxplot show the expression of top highly-expressed genes

For every gene, their UMI percentages in every cell were caculated and then used for comparison

sc.pl.highest_expr_genes(adata=scanpy_object, n_top=20, show=True, save=None, log=False)

    1. adata=: AnnData object used to plot
    1. n_top=: number of top highly-expressed genes to plot
    1. show=: if print the plot on scrren; default is "True"
    1. save=: if save the plot; default is "None"
    1. log=: if log the expression value; default is False

Based on the top highly-expressed genes, one can preliminarily estimate if there is some obvious error in the data, such like high expression of mitochondrial or ribosome-protein genes

sc.pl.highest_expr_genes(adata=scanpy_object_used, n_top=5)

sc.pl.violin()

https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.violin.html#scanpy.pl.violin

Violin plot of some important features

sc.pl.violin(adata, keys=, jitter=, multi_panel=)

    1. keys=: strings or list of strings; 指定用 .var/.obs 中的哪些 列(变量) 进行绘图
    1. jitter=: Boolean value; if add points to the whole plot; default is True
    1. multi_panel=: Boolean value; if plot in group; default is None

sc.pl.violin(scanpy_object_used, keys=['n_genes_by_counts', 'total_counts', 'pct_counts_mt'],jitter=0.4, multi_panel=True)

sc.pl.highly_variable_genes()

https://scanpy.readthedocs.io/en/stable/api/generated/scanpy.pl.highly_variable_genes.html#scanpy.pl.highly_variable_genes

Scatter plot to show the dispersion versus mean-expression of every gene

sc.pl.highly_variable_genes(scanpy_object_used)

    1. log=: log the axis; default=False
    1. highly_variable_genes=: highlight the highlt variable genes; default=True

sc.pl.highly_variable_genes(scanpy_object_used)

sc.pl.pca()

https://scanpy.readthedocs.io/en/stable/api/generated/scanpy.pl.pca.html

scatter plot of the PCA results

sc.pl.pca(scanpy_object, dimensions=, color=, show=)

    1. dimensions=: dimensions used for plot
    1. color=: feature for color
    1. show=: if plot the figure; default=True, plot the figure rather than return for plot; for return plot, it should be False

sc.pl.pca(scanpy_object, dimensions=[(0,1),(2,3)], color="total_counts")

sc.pl.pca_variance_ratio()

https://scanpy.readthedocs.io/en/stable/api/generated/scanpy.pl.pca_variance_ratio.html#scanpy.pl.pca_variance_ratio

plot show the contribution of every PC to the whole variance

sc.pl.pca_variance_ratio(adata, n_pcs=, log=)

    1. n_pcs=: number of PCs to plot; default=30
    1. log=: show the log value of y-axis; default=False

sc.pl.pca_variance_ratio(scanpy_object, log=True)
sc.pl.umap(scanpy_object, use_raw=False, color=['CST3', 'NKG7', 'PPBP'])

sc.pl.umap()

https://scanpy.readthedocs.io/en/stable/api/generated/scanpy.pl.umap.html#scanpy.pl.umap

plot base on UMAP results

sc.pl.umap(adata, use_raw=, layer=, color=, size=, palette=, legend_fontsize=, show=, legend_loc=)

    1. use_raw=: use the .raw data for plot or not; default=None, the .raw will be used for plotting
    1. layer=: key in .layer used for plot; de fault=None, .X will be used for plot
    1. color=: the key of .obs or .var used for color the plot
    1. size=: size of the scatter; 7 is good
    1. palette=: colors used for plot; 'Set1', 'Set2' and 'Set3' can be choosed
    1. legend_fontsize=: 指定图例中字体大小;选择 7 比较合适
    1. show=: if plot the figure; default=True, plot the figure rather than return for plot; for return plot, it should be False
    1. legend_loc=: 规定 legend 的位置;legend_loc=None 表示不绘制 legend

sc.pl.umap(scanpy_object, color=['leiden'], palette='Set1')

sc.pl.umap(scanpy_object, use_raw=False, color=['CST3', 'NKG7', 'PPBP'])

sc.pl.tsne()

https://scanpy.readthedocs.io/en/stable/api/generated/scanpy.pl.tsne.html#scanpy.pl.tsne

plot base on tSNE results

sc.pl.tsne(adata, use_raw=, layer=, color=, size=, palette=, legend_fontsize=, legend_loc=, show=, color_map=)

    1. use_raw=: use the .raw data for plot or not; default=None, the .raw will be used for plotting
    1. layer=: key in .layer used for plot; de fault=None, .X will be used for plot
    1. color=: the key of .obs or .var used for color the plot
    1. size=: size of the scatter; 7 is good
    1. palette=: colors used for plot; 'Set1', 'Set2' and 'Set3' can be choosed
    1. legend_fontsize=: 指定图例中字体大小;选择 7 比较合适
    1. legend_loc=: cluster 标记显示的位置;on data 表示标记在图中;legend_loc=None 表示不绘制 legend
    1. show=: if plot the figure; default=True, plot the figure rather than return for plot; for return plot, it should be False
    1. color_map=: 当用基因表达进行配色时,改变配色方案;viridis 为经典配色;viridis_r 为反向经典配色,比较常用

sc.pl.tsne(integration_of_Chem_FCA_and_AD_FCA, color="data", legend_fontsize='7')

sc.pl.violin()

https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.violin.html#scanpy.pl.violin

violin plot

sc.pl.violin(adata, groupby=, keys=)

    1. groupby=: group base on this; 'leiden'
    1. keys=: features to plot

sc.pl.violin(scanpy_object, groupby='leiden', keys=['n_genes'])

sc.pl.dotplot()

https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.dotplot.html#scanpy.pl.dotplot

dotplot

sc.pl.dotplot(adata, groupby=, var_names=, use_raw=, layer=, figsize=)

    1. groupby=: base on what to group; 'leiden'
    1. var_names=: features for plot
    1. use_raw=: if use the .raw.X for plot; default=None, the .raw.X will be used if present
    1. layer=: key in .layer used for plotting
    1. figsize=: size of the plot; (3, 2)

sc.pl.dotplot(scanpy_object, var_names=['TNFRSF4', 'CPSF3L', 'ATAD3C', 'C1orf86', 'RER1', 'TNFRSF25', 'TNFRSF9'], groupby='leiden')

sc.pl.stacked_violin()

https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.stacked_violin.html#scanpy.pl.stacked_violin

stacked violin plot

sc.pl.stacked_violin(adata, groupby=, var_names=, use_raw=, layer=, figsize=)

    1. groupby=: base on what to group; 'leiden'
    1. var_names=: features for plot
    1. use_raw=: if use the .raw.X for plot; default=None, the .raw.X will be used if present
    1. layer=: key in .layer used for plotting
    1. figsize=: size of the plot; (3, 2)

sc.pl.stacked_violin(scanpy_object, var_names=['TNFRSF4', 'CPSF3L', 'ATAD3C', 'C1orf86', 'RER1', 'TNFRSF25', 'TNFRSF9'], groupby='leiden', figsize=(4,2))

sc.pl.scatter()

https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.scatter.html#scanpy.pl.scatter

scatter plot

sc.pl.matrixplot()

https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.matrixplot.html#scanpy.pl.matrixplot

matrix plot: Create a heatmap of the mean expression values per group of each gene.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容