pinellolab / STREAM

STREAM: Single-cell Trajectories Reconstruction, Exploration And Mapping of single-cell data
http://stream.pinellolab.org
GNU Affero General Public License v3.0
168 stars 45 forks source link

legend text missing #103

Closed ccshao closed 3 years ago

ccshao commented 3 years ago

Here is a small but wired issue about legend text. The data set has three groups, which is correctly coloured, but one label in the legend is missing, only 2 are shown instead of 3.


import stream as st
import re

st.__version__
st.set_figure_params(dpi=80,
                     style='white',
                     figsize=[6.4, 5.8],
                     rc={'image.cmap': 'viridis'})

adata = st.read(file_name='wt_count.tsv.gz',
                workdir='./stream_result')

st.add_metadata(adata, file_name='wt_meta.tsv')

st.cal_qc(adata, assay='rna')
# st.filter_cells(adata, min_n_features=100)
st.filter_features(adata, min_n_cells=3)

###Normalize gene expression based on library size
st.normalize(adata, method='lib_size')
###Logarithmize gene expression
st.log_transform(adata)
###Remove mitochondrial genes
st.remove_mt_genes(adata)

st.select_variable_genes(adata, loess_frac=0.01, percentile=95, save_fig=True)

st.dimension_reduction(adata,
                       n_components=2,
                       method='se',
                       feature='var_genes',
                       n_jobs=12)

st.plot_dimension_reduction(adata,
                            color=['label'],
                            n_components=2,
                            show_graph=False,
                            show_text=False,
                            save_fig=True)

Screenshot_2020-12-14_16-41-27

huidongchen commented 3 years ago

Would you mind sharing with me the versions of seaborn and matplotlib? It seemingly has something to do with the latest version of seaborn.

ccshao commented 3 years ago

See the following package detials. I feel that the first one in groups is ignored, in the above case the first one is "WT_IP".

~ $ conda list                                    (env_stream)
matplotlib-base           3.3.3            py37h4f6019d_0    conda-forge
seaborn                   0.11.0               ha770c72_1    conda-forge
seaborn-base              0.11.0             pyhd8ed1ab_1    conda-forge
huidongchen commented 3 years ago

I have noticed that latest version of seaborn indeed caused some weird issues. Can you first try to downgrade seaborn to 0.10.1?

If it doesn't solve the problem, can you share with me the coordinates of cells by saving them as a .tsv file? happy to take a look.

import pandas as pd
pd.concat([adata.obs['label'],pd.DataFrame(index=adata.obs_names,data=adata.obsm['X_dr'])],axis=1).to_csv('coord.tsv',sep='\t')
ccshao commented 3 years ago

You are right with seaborn, the earlier version fixed the issue. Many thanks for the quick guides!