STOmics / Stereopy

A toolkit of spatial transcriptomic analysis.
MIT License
180 stars 59 forks source link

data.plt.cells_plotting #238

Closed heziqing closed 4 months ago

heziqing commented 5 months ago

Hello, everyone I used data.plt.cells_plotting to visualize the detail of cells, but it could not work and did not send any error. And the output is a blank figure. The following is my code and the version of Stereopy is v.1.0.0. Thanks for your help in advance. ` import stereo as st import warnings warnings.filterwarnings('ignore') st.version ## '1.0.0'

from matplotlib import pyplot as plt import os os.chdir("./cellpose/TH6")

tmpsample="TH6" regist_ID={"TH4":"A02997C1","TH6":"A02996F4"} data_path = "/Stereopy/cellpose/"+tmpsample+"/"+regist_ID[tmpsample]+".cellbin.gef" st.io.read_gef_info(data_path) data = st.io.read_gef(file_path=data_path, bin_type='cell_bins') ## 108332 data.tl.cal_qc() data.tl.filter_cells( min_gene=100, min_n_genes_by_counts=3, max_n_genes_by_counts=2000, inplace=True ) ## 23177 cells data

data.tl.raw_checkpoint() ## save the raw expression matrix data.tl.raw data.tl.normalize_total(target_sum=10000) data.tl.log1p()

data.tl.highly_variable_genes( min_mean=0.0125, max_mean=3, min_disp=0.5, n_top_genes=2000, res_key='highly_variable_genes' )

data.tl.scale() data.tl.pca( use_highly_genes=True, n_pcs=30, res_key='pca' )

data.tl.neighbors(pca_res_key='pca', res_key='neighbors') data.tl.umap(pca_res_key='pca', neighbors_res_key='neighbors', res_key='umap')

data.tl.leiden(neighbors_res_key='neighbors', res_key='leiden')

figure = plt.figure(figsize=(10, 10)) plt.tight_layout() data.plt.cluster_scatter(res_key='leiden',dot_size=0.01) plt.savefig(tmpsample+"_cluster_scatter_plot_filter_cells.pdf", format="pdf", bbox_inches="tight")

figure = plt.figure(figsize=(10, 10)) plt.tight_layout() data.plt.cells_plotting(cluster_res_key='cluster') plt.savefig(tmpsample+"_cellbin_plot_filter_cells.pdf", format="pdf", bbox_inches="tight") `

Zhenbin24 commented 5 months ago

Hello, you can try this way to save the picture.

image

tanliwei-coder commented 5 months ago

Try to restart the browser and rerun the workflow, and, this is not plotted by matplotlib, it cat not be saved by plt.savefig, you can save it through the method mentioned above.