Skip to content

Unexpected grid potential caused by seaborn or scanpy #60

Description

@DingWB

When other packages are imported, such as seaborn and set some kind of style, there would be a unexpected grid in heatmap

import os,sys
%matplotlib inline
import matplotlib.pylab as plt
import pickle
plt.rcParams['figure.dpi'] = 100
plt.rcParams['savefig.dpi']=300
plt.rcParams['font.family']='sans serif'
plt.rcParams['font.sans-serif']='Arial'
plt.rcParams['pdf.fonttype']=42
import pandas as pd
from PyComplexHeatmap import *
import PyComplexHeatmap as pch
print(pch.__version__)
import scanpy
#import seaborn as sns
# sns.set_style("whitegrid")
# sns.set_style("white")
df_row=pd.read_csv("df_row.csv",index_col=0)
df_row.spatial_domain=df_row.spatial_domain.astype(str)
df_col=pd.read_csv("df_col.csv",index_col=0)
df_col.chromosome=df_col.chromosome.astype(str)
data=pd.read_csv("cnv_mtr_filtered.csv",index_col=0)
df_col=df_col.sample(500)
data=data.loc[:,df_col.index.tolist()]
data
plt.figure(figsize=(10, 5))


right_annotation = HeatmapAnnotation(
                **,
                       axis=0)

top_annotation = HeatmapAnnotation(
    
                label=anno_label(df_col['chromosome'],merge=True, rotation=90),
                chromosome = anno_simple(df_col['chromosome'], add_text=False, legend_kws={'frameon':False}, 
                                         colors= dict(zip(np.arange(1,23).astype(str),['#5daab4','#000000']*11)), 
                                         legend=True), axis=1)

cm = ClusterMapPlotter(data=data, 
                       vmax=1.02, vmin=0.98, 
                       top_annotation=top_annotation,   
                       left_annotation =right_annotation ,
                       cmap='RdBu_r',  
                       row_cluster=False, col_cluster=False, 
                        col_split = df_col['chromosome'], 
                       col_split_order = [str(i) for i in list(range(1,23))],
                       col_split_gap=0.4 
                      )

When use sns.set_style("whitegrid")
or change setting in scanpy:

import scanpy
sc.settings.verbosity = 3 
sc.settings.set_figure_params(dpi=100, dpi_save=300,
                              facecolor='white', figsize=(4,4))

An unexpected grid would appear:
image

When set sns.set_style("whitegrid") or in default, the heatmap looks good:
image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions