def test_violin(): sc.pl.set_rcParams_defaults() sc.set_figure_params(dpi=80, color_map='viridis') pbmc = sc.datasets.pbmc68k_reduced() sc.pl.violin(pbmc, ['n_genes', 'percent_mito', 'n_counts'], stripplot=True, multi_panel=True, jitter=True, show=False) save_and_compare_images('master_violin_multi_panel', tolerance=40)
def make_violin_images_multi(): #### # tests based on pbmc68k_reduced dataset sc.pl.set_rcParams_defaults() sc.set_figure_params(dpi=80, color_map='viridis') pbmc = sc.datasets.pbmc68k_reduced() sc.pl.violin(pbmc, ['n_genes', 'percent_mito', 'n_counts'], stripplot=False, multi_panel=True, jitter=False) pl.savefig("master_violin_multi_panel.png", dpi=80) pl.close()
def test_violin(): sc.pl.set_rcParams_defaults() sc.set_figure_params(dpi=80, color_map='viridis') pbmc = sc.datasets.pbmc68k_reduced() outfile = NamedTemporaryFile(suffix='.png', prefix='scanpy_test_violin_', delete=False) sc.pl.violin(pbmc, ['n_genes', 'percent_mito', 'n_counts'], stripplot=True, multi_panel=True, jitter=True, show=False) pl.savefig(outfile.name, dpi=80) pl.close() res = compare_images(ROOT + '/master_violin_multi_panel.png', outfile.name, 40) assert res is None, res os.remove(outfile.name)
# -*- coding: utf-8 -*- import matplotlib as mpl mpl.use('agg') import matplotlib.pyplot as pl import scanpy.api as sc sc.set_figure_params(dpi=80, color_map='viridis') def make_heatmaps(): adata = sc.datasets.krumsiek11() # make heatmap sc.pl.heatmap(adata, adata.var_names, 'cell_type', use_raw=False) pl.savefig('master_heatmap.png', dpi=80) pl.close() # make heatmap with continues data adata.obs['Gata2'] = adata.X[:, 0] sc.pl.heatmap(adata, adata.var_names, 'Gata2', use_raw=False, num_categories=4, figsize=(4.5, 5)) pl.savefig('master_heatmap2.png', dpi=80) pl.close()
df = df.replace(regex=r' ', value='_').replace(regex=r'/', value='_') df.to_csv('%s/DEGs/cell_groups.csv' %(outdir), sep="\t", index=False) grpList = ','.join(list(set(df['sampleCluster'].values))) os.system('Rscript %s/diff_expr.R %s/DEGs/expr.csv %s/DEGs %s/DEGs/cell_groups.csv %s kw 0.01 5000 TRUE 4 v2 1 conover FALSE median FALSE' %(indir, outdir, outdir, outdir, outdir)) ## Trajectory analysis cell_annot = df.loc[rpkms.columns] import numpy as np import pandas as pd import matplotlib.pyplot as pl from matplotlib import rcParams import scanpy.api as sc rcParams['pdf.fonttype'] = 42 sc.set_figure_params(color_map='viridis') expr_data = rpkms.copy() sample_cluster=cell_annot['sampleCluster'] X = expr_data.values gene_names = list(expr_data.index) sample_names = list(expr_data.columns) adata = sc.AnnData(X.transpose()) adata.var_names = gene_names adata.row_names = sample_names sc.settings.figdir = outdir genes = list(set(list(set(sigVarGenes))
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import numpy as np import pandas as pd import matplotlib.pyplot as pl import scanpy.api as sc #print("hello world") #pl.plot(arange(5)) sc.set_figure_params( dpi=100) # low dpi (dots per inch) yields small inline figures sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3) sc.logging.print_versions() results_file = '../results/paga_test/planaria_extended.h5ad' paga_plot_params = dict(legend_fontsize=5, solid_edges='confidence_tree', dashed_edges='confidence', root='neoblast 1', layout='rt_circular', node_size_scale=0.5, node_size_power=0.9, max_edge_width=0.7, fontsize=3.5)