# Developing-Heart-Local-Improved - Rna Integration

**Pages:** 64

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Epicardium/RenamingPericardialCells.html

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-06-23 12:09.
```

Example 5 (python):
```python
adata=sc.read('./Objects/Feb28ObjectProcessed.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(297473, 3392)
```

Example 7 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 8 (unknown):
```unknown
(297473, 36601)
```

Example 9 (python):
```python
#Combine all barcodes
CoronaryPericytes=[x.strip() for x in open('./Index/Mesenchymal/CoronaryPericytes.txt')]
CoronarySmoothMuscleCells=[x.strip() for x in open('./Index/Mesenchymal/CoronarySmoothMuscleCells.txt')]
CoronaryVesselAdventitialFibroblasts=[x.strip() for x in open('./Index/Mesenchymal/CoronaryVesselAdventitialFibroblasts.txt')]
DuctusArteriosusSmoothMuscleCells=[x.strip() for x in open('./Index/Mesenchymal/DuctusArteriosusSmoothMuscleCells.txt')]
GreatVesselAdventitialFibroblasts=[x.strip() for x in open('./Index/Mesenchymal/GreatVesselAdventitialFibroblasts.txt')]
GreatVesselSmoothMuscleCells=[x.strip() for x in open('./Index/Mesenchymal/GreatVesselSmoothMuscleCells.txt')]
LymphNodeFibroblasticReticularCells=[x.strip() for x in open('./Index/Mesenchymal/LymphNodeFibroblasticReticularCells.txt')]
MyocardialInterstitialFibroblasts1=[x.strip() for x in open('./Index/Mesenchymal/MyocardialInterstitialFibroblasts1.txt')]
MyocardialInterstitialFibroblasts2=[x.strip() for x in open('./Index/Mesenchymal/MyocardialInterstitialFibroblasts2.txt')]
Myofibroblasts=[x.strip() for x in open('./Index/Mesenchymal/Myofibroblasts.txt')]
PericardialCells1=[x.strip() for x in open('./Index/Mesenchymal/PericardialCells1.txt')]
PericardialCells2=[x.strip() for x in open('./Index/Mesenchymal/PericardialCells2.txt')]
PericardialCells3=[x.strip() for x in open('./Index/Mesenchymal/PericardialCells3.txt')]
ValveInterstitialCells=[x.strip() for x in open('./Index/Mesenchymal/ValveInterstitialCells.txt')]
MesenchymalIndex=CoronaryPericytes+CoronarySmoothMuscleCells+CoronaryVesselAdventitialFibroblasts+DuctusArteriosusSmoothMuscleCells+GreatVesselAdventitialFibroblasts+LymphNodeFibroblasticReticularCells+GreatVesselSmoothMuscleCells+MyocardialInterstitialFibroblasts1+MyocardialInterstitialFibroblasts2+Myofibroblasts+PericardialCells1+PericardialCells2+PericardialCells3+ValveInterstitialCells

AtrialCardiomyocytesCycling=[x.strip() for x in open('./Index/Cardiomyocytes/AtrialCardiomyocytesCycling.txt')]
AtrialCardiomyocytesLeft=[x.strip() for x in open('./Index/Cardiomyocytes/AtrialCardiomyocytesLeft.txt')]
AtrialCardiomyocytesRight=[x.strip() for x in open('./Index/Cardiomyocytes/AtrialCardiomyocytesRight.txt')]
AtrioventricularNodeCardiomyocytes=[x.strip() for x in open('./Index/Cardiomyocytes/AtrioventricularNodeCardiomyocytes.txt')]
SinoatrialNodeCardiomyocytes=[x.strip() for x in open('./Index/Cardiomyocytes/SinoatrialNodeCardiomyocytes.txt')]
VentricularCardiomyocytesCycling=[x.strip() for x in open('./Index/Cardiomyocytes/VentricularCardiomyocytesCycling.txt')]
VentricularCardiomyocytesLeftCompact=[x.strip() for x in open('./Index/Cardiomyocytes/VentricularCardiomyocytesLeftCompact.txt')]
VentricularCardiomyocytesLeftTrabeculated=[x.strip() for x in open('./Index/Cardiomyocytes/VentricularCardiomyocytesLeftTrabeculated.txt')]
VentricularCardiomyocytesRightCompact=[x.strip() for x in open('./Index/Cardiomyocytes/VentricularCardiomyocytesRightCompact.txt')]
VentricularCardiomyocytesRightTrabeculated=[x.strip() for x in open('./Index/Cardiomyocytes/VentricularCardiomyocytesRightTrabeculated.txt')]
VentricularConductionSystemDistal=[x.strip() for x in open('./Index/Cardiomyocytes/VentricularConductionSystemDistal.txt')]
VentricularConductionSystemProximal=[x.strip() for x in open('./Index/Cardiomyocytes/VentricularConductionSystemProximal.txt')]
CardiomyocyteIndex=AtrialCardiomyocytesCycling+AtrialCardiomyocytesLeft+AtrialCardiomyocytesRight+AtrioventricularNodeCardiomyocytes+SinoatrialNodeCardiomyocytes+VentricularCardiomyocytesLeftCompact+VentricularCardiomyocytesCycling+VentricularCardiomyocytesRightTrabeculated+VentricularCardiomyocytesRightCompact+VentricularCardiomyocytesLeftTrabeculated+VentricularConductionSystemDistal+VentricularConductionSystemProximal

CoronaryArterialEndothelialCells=[x.strip() for x in open('./Index/Endothelium/CoronaryArterialEndothelialCells.txt')]
CoronaryCapillaryEndothelialCells=[x.strip() for x in open('./Index/Endothelium/CoronaryCapillaryEndothelialCells.txt')]
CoronaryVenousEndothelialCells=[x.strip() for x in open('./Index/Endothelium/CoronaryVenousEndothelialCells.txt')]
EndocardialCells=[x.strip() for x in open('./Index/Endothelium/EndocardialCells.txt')]
EndocardialCushionCells=[x.strip() for x in open('./Index/Endothelium/EndocardialCushionCells.txt')]
GreatVesselArterialEndothelialCells=[x.strip() for x in open('./Index/Endothelium/GreatVesselArterialEndothelialCells.txt')]
GreatVesselVenousEndothelialCells=[x.strip() for x in open('./Index/Endothelium/GreatVesselVenousEndothelialCells.txt')]
LymphaticEndothelialCells=[x.strip() for x in open('./Index/Endothelium/LymphaticEndothelialCells.txt')]
ValveEndothelialCells=[x.strip() for x in open('./Index/Endothelium/ValveEndothelialCells.txt')]
EndotheliumIndex=CoronaryArterialEndothelialCells+CoronaryCapillaryEndothelialCells+CoronaryVenousEndothelialCells+EndocardialCells+EndocardialCushionCells+GreatVesselArterialEndothelialCells+GreatVesselVenousEndothelialCells+LymphaticEndothelialCells+ValveEndothelialCells

EpicardiumDerivedCells=[x.strip() for x in open('./Index/Epicardium/EpicardiumDerivedCells.txt')]
MesothelialEpicardialCells=[x.strip() for x in open('./Index/Epicardium/MesothelialEpicardialCells.txt')]
EpicardiumIndex=EpicardiumDerivedCells+MesothelialEpicardialCells

SchwannCells=[x.strip() for x in open('./Index/Neural/SchwannCells.txt')]
SchwannCellPrecursors=[x.strip() for x in open('./Index/Neural/SchwannCellPrecursors.txt')]
ChromaffinCells=[x.strip() for x in open('./Index/Neural/ChromaffinCells.txt')]
NeuronPrecursors=[x.strip() for x in open('./Index/Neural/NeuronPrecursors.txt')]
ParasympatheticNeurons=[x.strip() for x in open('./Index/Neural/ParaympatheticNeurons.txt')]
SympatheticNeurons=[x.strip() for x in open('./Index/Neural/SympatheticNeurons.txt')]
NeuralIndex=ChromaffinCells+NeuronPrecursors+ParasympatheticNeurons+SchwannCellPrecursors+SchwannCells+SympatheticNeurons

BCells=[x.strip() for x in open('./Index/Immune/BCells.txt')]
BCellsMS4A1pos=[x.strip() for x in open('./Index/Immune/BCellsMS4A1pos.txt')]
TCellsCD4pos=[x.strip() for x in open('./Index/Immune/TCellsCD4pos.txt')]
TregsCD4pos=[x.strip() for x in open('./Index/Immune/TregsCD4pos.txt')]
TCellsCD8pos=[x.strip() for x in open('./Index/Immune/TCellsCD8pos.txt')]
DendriticCellsType1=[x.strip() for x in open('./Index/Immune/DendriticCellsType1.txt')]
DendriticCellsMature=[x.strip() for x in open('./Index/Immune/DendriticCellsMature.txt')]
InnateLymphoidCells=[x.strip() for x in open('./Index/Immune/InnateLymphoidCells.txt')]
MacrophagesATF3pos=[x.strip() for x in open('./Index/Immune/MacrophagesATF3pos.txt')]
MacrophagesCX3CR1pos=[x.strip() for x in open('./Index/Immune/MacrophagesCX3CR1pos.txt')]
MacrophagesLYVE1pos=[x.strip() for x in open('./Index/Immune/MacrophagesLYVE1pos.txt')]
MacrophagesTIMD4pos=[x.strip() for x in open('./Index/Immune/MacrophagesTIMD4pos.txt')]
MastCells=[x.strip() for x in open('./Index/Immune/MastCells.txt')]
Megakaryocytes=[x.strip() for x in open('./Index/Immune/Megakaryocytes.txt')]
MonocyteDerivedCells=[x.strip() for x in open('./Index/Immune/MonocyteDerivedCells.txt')]
Monocytes=[x.strip() for x in open('./Index/Immune/Monocytes.txt')]
MonocytesMPOpos=[x.strip() for x in open('./Index/Immune/MonocytesMPOpos.txt')]
NaturalKillerCells=[x.strip() for x in open('./Index/Immune/NaturalKillerCells.txt')]
PlasmacytoidDendriticCells=[x.strip() for x in open('./Index/Immune/PlasmacytoidDendriticCells.txt')]
ProBCells=[x.strip() for x in open('./Index/Immune/ProBCells.txt')]

ImmuneIndex=BCells+BCellsMS4A1pos+TCellsCD4pos+TregsCD4pos+TCellsCD8pos+DendriticCellsType1+DendriticCellsMature+InnateLymphoidCells+MacrophagesATF3pos+MacrophagesCX3CR1pos+MacrophagesLYVE1pos+MacrophagesTIMD4pos+MastCells+Megakaryocytes+MonocyteDerivedCells+Monocytes+MonocytesMPOpos+NaturalKillerCells+PlasmacytoidDendriticCells+ProBCells

AllIndex=MesenchymalIndex+CardiomyocyteIndex+EndotheliumIndex+ImmuneIndex+EpicardiumIndex+NeuralIndex
print(len(AllIndex))
```

Example 10 (python):
```python
adata.obs['fine_grain']= 'na'

adata.obs['fine_grain'][[x for x in adata.obs_names if x in CoronaryPericytes]]='CoronaryPericytes'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in CoronarySmoothMuscleCells]]='CoronarySmoothMuscleCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in CoronaryVesselAdventitialFibroblasts]]='CoronaryVesselAdventitialFibroblasts'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in DuctusArteriosusSmoothMuscleCells]]='DuctusArteriosusSmoothMuscleCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in GreatVesselAdventitialFibroblasts]]='GreatVesselAdventitialFibroblasts'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in LymphNodeFibroblasticReticularCells]]='LymphNodeFibroblasticReticularCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in GreatVesselSmoothMuscleCells]]='GreatVesselSmoothMuscleCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MyocardialInterstitialFibroblasts1]]='MyocardialInterstitialFibroblasts'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MyocardialInterstitialFibroblasts2]]='SubEpicardialFibroblasts'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in Myofibroblasts]]='Myofibroblasts'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in PericardialCells1]]='PericardialCellsIntermediate'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in PericardialCells2]]='PericardialCellsFibrous'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in PericardialCells3]]='PericardialCellsParietal'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in ValveInterstitialCells]]='ValveInterstitialCells'

adata.obs['fine_grain'][[x for x in adata.obs_names if x in AtrialCardiomyocytesCycling]]='AtrialCardiomyocytesCycling'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in AtrialCardiomyocytesLeft]]='AtrialCardiomyocytesLeft'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in AtrialCardiomyocytesRight]]='AtrialCardiomyocytesRight'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in AtrioventricularNodeCardiomyocytes]]='AtrioventricularNodePacemakerCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in SinoatrialNodeCardiomyocytes]]='SinoatrialNodePacemakerCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in VentricularCardiomyocytesLeftCompact]]='VentricularCardiomyocytesLeftCompact'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in VentricularCardiomyocytesCycling]]='VentricularCardiomyocytesCycling'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in VentricularCardiomyocytesRightTrabeculated]]='VentricularCardiomyocytesRightTrabeculated'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in VentricularCardiomyocytesRightCompact]]='VentricularCardiomyocytesRightCompact'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in VentricularCardiomyocytesLeftTrabeculated]]='VentricularCardiomyocytesLeftTrabeculated'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in VentricularConductionSystemDistal]]='VentricularConductionSystemDistal'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in VentricularConductionSystemProximal]]='VentricularConductionSystemProximal'

adata.obs['fine_grain'][[x for x in adata.obs_names if x in CoronaryArterialEndothelialCells]]='CoronaryArterialEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in CoronaryCapillaryEndothelialCells]]='CoronaryCapillaryEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in CoronaryVenousEndothelialCells]]='CoronaryVenousEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in EndocardialCells]]='EndocardialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in EndocardialCushionCells]]='EndocardialCushionCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in GreatVesselArterialEndothelialCells]]='GreatVesselArterialEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in GreatVesselVenousEndothelialCells]]='GreatVesselVenousEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in LymphaticEndothelialCells]]='LymphaticEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in ValveEndothelialCells]]='ValveEndothelialCells'

adata.obs['fine_grain'][[x for x in adata.obs_names if x in EpicardiumDerivedCells]]='EpicardiumDerivedCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MesothelialEpicardialCells]]='MesothelialEpicardialCells'

adata.obs['fine_grain'][[x for x in adata.obs_names if x in ChromaffinCells]]='ChromaffinCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in NeuronPrecursors]]='NeuronPrecursors'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in ParasympatheticNeurons]]='ParasympatheticNeurons'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in SchwannCellPrecursors]]='SchwannCellPrecursors'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in SchwannCells]]='SchwannCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in SympatheticNeurons]]='SympatheticNeurons'

adata.obs['fine_grain'][[x for x in adata.obs_names if x in BCells]]='BCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in BCellsMS4A1pos]]='BCellsMS4A1pos'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in DendriticCellsType1]]='DendriticCellsType1'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in DendriticCellsMature]]='DendriticCellsMature'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in InnateLymphoidCells]]='InnateLymphoidCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MacrophagesATF3pos]]='MacrophagesATF3pos'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MacrophagesCX3CR1pos]]='MacrophagesCX3CR1pos'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MacrophagesLYVE1pos]]='MacrophagesLYVE1pos'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MacrophagesTIMD4pos]]='MacrophagesTIMD4pos'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MastCells]]='MastCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in Megakaryocytes]]='Megakaryocytes'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MonocyteDerivedCells]]='MonocyteDerivedCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in Monocytes]]='Monocytes'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in MonocytesMPOpos]]='MonocytesMPOpos'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in NaturalKillerCells]]='NaturalKillerCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in PlasmacytoidDendriticCells]]='PlasmacytoidDendriticCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in ProBCells]]='ProBCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in TCellsCD4pos]]='TCellsCD4pos'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in TregsCD4pos]]='TregsCD4pos'
adata.obs['fine_grain'][[x for x in adata.obs_names if x in TCellsCD8pos]]='TCellsCD8pos'

sc.pl.umap(adata, color=['fine_grain'])
```

Example 11 (unknown):
```unknown
... storing 'fine_grain' as categorical
```

Example 12 (python):
```python
sc.pl.umap(adata, color=['mid_grain'])
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 297473 × 3392
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 14 (python):
```python
adata.write('./Objects/Feb28ObjectProcessed.h5ad')
#adata
```

Example 15 (python):
```python
adata.write('./Objects/Feb28ObjectRaw.h5ad')
#adata
```

Example 16 (unknown):
```unknown
AnnData object with n_obs × n_vars = 297473 × 3392
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 17 (python):
```python
sc.pl.umap(adata, color=['fine_grain'])
```

Example 18 (unknown):
```unknown
AnnData object with n_obs × n_vars = 297473 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_EpicardialCells.html

**Contents:**
- Variables¶
- Read in data¶
- Markers¶
- 1st round annotation¶
- Save¶

--> cluster 0 has lower total counts and smaller cell area, but has mesothelial marker gene expression --> retain

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-09 22:38
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'EpicardialCells'
```

Example 10 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 5206 × 4657
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([3.773983, 3.773983, 3.773983, 3.773983, 3.773983], dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 3.38 s, sys: 79.9 ms, total: 3.46 s
Wall time: 3.47 s
```

Example 21 (python):
```python
# read in markers identified using single-nucleus data
markers_df = pd.read_csv(f'/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_{celltype}_finegrain_markers.csv')

mask1 = markers_df['group_mean']>1
mask2 = markers_df['logfoldchanges']>1
markers_df = markers_df[mask1&mask2]

markers_df
```

Example 22 (python):
```python
markers = {}
n_top = 100
for c in set(markers_df['group']):
    markers_df_sub = markers_df[markers_df['group']==c]
    markers_df_sub.sort_values('logfoldchanges',ascending=False)
    markers[c]=list(markers_df_sub[:n_top]['names'])

# manually add genes
markers['Cycling'] = ['MKI67','TOP2A'] 

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in list(adata.var_names))&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in list(adata.var_names)]
len(genes)
```

Example 23 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",color=genes, size=20,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 24 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",
                color=['celltypist_midmod2fine', 'conf_score_midmod2fine'],
                wspace=0.7)
```

Example 25 (python):
```python
# umap per celltype to highlight
group_col = 'celltypist_midmod2fine'
groups_to_plot = list(set(adata.obs[group_col]))

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,7))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",
                    color=[group_col], groups=grp, 
               size=30, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 26 (unknown):
```unknown
resolution_sel = 0.6
```

Example 27 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              markers_others, 
              groupby=f'leiden_{str(resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 28 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 29 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 30 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: MesothelialEpicardialCells, EpicardiumDerivedCells, Cycling
```

Example 31 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 32 (unknown):
```unknown
[3.773983 3.773983 3.773983 3.773983 3.773983]
```

Example 33 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 34 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 35 (python):
```python
# annotate
adata.obs['fine_grain_manual'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'fine_grain_manual':{
    '0':'MesothelialEpicardialCells',
    '1':'MesothelialEpicardialCells',
    '2':'?EpithelialCells',
    '3':'MesothelialEpicardialCells',
    '4':'MesothelialEpicardialCells',
    '5':'?ThyroidCells',
    '6':'EpicardiumDerivedCells',
}},inplace=True)
adata.obs['fine_grain_manual'].value_counts()
```

Example 36 (python):
```python
/tmp/ipykernel_70466/3275159660.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'fine_grain_manual':{
```

Example 37 (unknown):
```unknown
fine_grain_manual
MesothelialEpicardialCells    3513
?EpithelialCells               786
?ThyroidCells                  518
EpicardiumDerivedCells         389
Name: count, dtype: int64
```

Example 38 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 39 (python):
```python
sc.tl.dendrogram(adata,groupby='fine_grain_manual')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 40 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: MesothelialEpicardialCells, ?EpithelialCells, ?ThyroidCells, etc.
var_group_labels: MesothelialEpicardialCells, EpicardiumDerivedCells, Cycling
```

Example 41 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=60,vmax='p100')
```

Example 42 (python):
```python
/tmp/ipykernel_70466/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 43 (python):
```python
/tmp/ipykernel_70466/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 44 (python):
```python
/tmp/ipykernel_70466/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 45 (python):
```python
/tmp/ipykernel_70466/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 46 (python):
```python
/tmp/ipykernel_70466/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 47 (python):
```python
/tmp/ipykernel_70466/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 48 (python):
```python
/tmp/ipykernel_70466/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 49 (python):
```python
/tmp/ipykernel_70466/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 50 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 51 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_EpicardialCells_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig5_Trisomy21/no04_euploid-trisomy21_scVI.html

**Contents:**
- Import modules¶
- Read in anndata¶
- Run scVI, categorical covariates to correct: donor+region¶
- Run scVI, categorical covariates to correct: only region¶
- Run scVI, categorical covariates to correct: only donor¶

**Examples:**

Example 1 (python):
```python
# this is for the jupyter notebook at JupyterLab
# to make sys.path between the terminal and Jupyter same
import sys

print(sys.path) # especially the path to site-packages are different... so thats why couldn't find correct package...

# sys.path from terminal at scvi0190_env
# obtained by excuting `python -c "import sys; print('\n'.join(sys.path))"`
sys.path = [
    "/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python39.zip",
    "/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9",
    "/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/lib-dynload",
    "/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages"
]

print(sys.path)
```

Example 2 (unknown):
```unknown
['/nfs/team205/kk18/notebooks/Foetal/Trisomy21/RNA', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python39.zip', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/lib-dynload', '', '/nfs/users/nfs_k/kk18/.local/lib/python3.9/site-packages', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages']
['/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python39.zip', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/lib-dynload', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages']
```

Example 3 (python):
```python
# import warnings
# warnings.simplefilter("ignore", UserWarning)

import anndata
import matplotlib.pyplot as plt
import seaborn as sns

import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc

import scvi
```

Example 4 (python):
```python
Global seed set to 0
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/flax/core/frozen_dict.py:169: FutureWarning: jax.tree_util.register_keypaths is deprecated, and will be removed in a future release. Please use `register_pytree_with_keys()` instead.
  jax.tree_util.register_keypaths(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/pytorch_lightning/utilities/warnings.py:53: LightningDeprecationWarning: pytorch_lightning.utilities.warnings.rank_zero_deprecation has been deprecated in v1.6 and will be removed in v1.8. Use the equivalent function from the pytorch_lightning.utilities.rank_zero module instead.
  new_rank_zero_deprecation(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/pytorch_lightning/utilities/warnings.py:58: LightningDeprecationWarning: The `pytorch_lightning.loggers.base.rank_zero_experiment` is deprecated in v1.7 and will be removed in v1.9. Please use `pytorch_lightning.loggers.logger.rank_zero_experiment` instead.
  return new_rank_zero_deprecation(*args, **kwargs)
```

Example 5 (python):
```python
import gc
import torch
```

Example 6 (python):
```python
import session_info
session_info.show()
```

Example 7 (python):
```python
-----
anndata             0.8.0
matplotlib          3.7.1
numpy               1.23.5
pandas              1.5.3
scanpy              1.9.3
scvi                0.19.0
seaborn             0.12.2
session_info        1.0.0
torch               1.13.1+cu117
-----
```

Example 8 (python):
```python
PIL                 9.4.0
absl                NA
asttokens           NA
attr                22.2.0
backcall            0.2.0
certifi             2022.12.07
cffi                1.15.1
charset_normalizer  3.1.0
chex                0.1.6
comm                0.1.2
contextlib2         NA
cycler              0.10.0
cython_runtime      NA
dateutil            2.8.2
debugpy             1.6.6
decorator           5.1.1
defusedxml          0.7.1
deprecate           0.3.2
docrep              0.3.2
etils               1.1.0
executing           1.2.0
flax                0.6.7
fsspec              2023.3.0
google              NA
h5py                3.8.0
idna                3.4
igraph              0.10.4
importlib_metadata  NA
importlib_resources NA
ipykernel           6.21.3
ipython_genutils    0.2.0
ipywidgets          8.0.4
jax                 0.4.10
jaxlib              0.4.10
jedi                0.18.2
joblib              1.2.0
kiwisolver          1.4.4
leidenalg           0.9.1
llvmlite            0.39.1
ml_collections      NA
ml_dtypes           0.2.0
mpl_toolkits        NA
msgpack             1.0.5
mudata              0.2.1
multipledispatch    0.6.0
natsort             8.3.1
numba               0.56.4
numpyro             0.11.0
nvidia              NA
opt_einsum          v3.3.0
optax               0.1.4
packaging           23.0
parso               0.8.3
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
platformdirs        3.1.1
prompt_toolkit      3.0.38
psutil              5.9.4
ptyprocess          0.7.0
pure_eval           0.2.2
pydev_ipython       NA
pydevconsole        NA
pydevd              2.9.5
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.14.0
pyparsing           3.0.9
pyro                1.8.4
pytorch_lightning   1.7.7
pytz                2022.7.1
requests            2.28.2
rich                NA
scipy               1.10.1
setuptools          65.6.3
six                 1.16.0
sklearn             1.2.2
stack_data          0.6.2
statsmodels         0.13.5
tensorboard         2.12.0
texttable           1.6.7
threadpoolctl       3.1.0
toolz               0.12.0
torchmetrics        0.11.4
torchvision         0.14.1+cu117
tornado             6.2
tqdm                4.65.0
traitlets           5.9.0
tree                0.1.8
typing_extensions   NA
urllib3             1.26.15
wcwidth             0.2.6
yaml                6.0
zipp                NA
zmq                 25.0.1
zoneinfo            NA
```

Example 9 (unknown):
```unknown
-----
IPython             8.11.0
jupyter_client      8.0.3
jupyter_core        5.2.0
notebook            6.5.3
-----
Python 3.9.16 (main, Mar  8 2023, 14:00:05) [GCC 11.2.0]
Linux-5.15.0-117-generic-x86_64-with-glibc2.35
-----
Session information updated at 2024-08-15 15:09
```

Example 10 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=80, facecolor='white', color_map = 'RdPu',)
```

Example 11 (python):
```python
# import own function
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/nfs/team205/kk18/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 12 (python):
```python
import os
os.getcwd()
```

Example 13 (unknown):
```unknown
'/nfs/team205/kk18/notebooks/Foetal/Trisomy21/RNA'
```

Example 14 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor.h5ad')
adata
```

Example 15 (unknown):
```unknown
AnnData object with n_obs × n_vars = 83477 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'euploid_or_t21', 'donor_type', 'region_finest', 'flushed', 'scrublet_leiden', 'cluster_scrublet_score', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'celltypist_fine', 'conf_score_fine', 'coarse_grain_merged', 'fine_grain_merged'
    var: 'gene_id', 'gene_name_scRNA-0-0', 'feature_type-1', 'ambient_expression-0-1', 'ambient_expression-1-1', 'ambient_expression-10-1', 'ambient_expression-11-1', 'ambient_expression-12-1', 'ambient_expression-13-1', 'ambient_expression-14-1', 'ambient_expression-2-1', 'ambient_expression-3-1', 'ambient_expression-4-1', 'ambient_expression-5-1', 'ambient_expression-6-1', 'ambient_expression-7-1', 'ambient_expression-8-1', 'ambient_expression-9-1', 'mt-1', 'ribo-1', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
```

Example 16 (python):
```python
# Setup anndata for scVI
bdata = adata.copy()
scvi.model.SCVI.setup_anndata(bdata, 
                              # layer="counts", 
                              batch_key="donor", # we want to correct for this 
                              categorical_covariate_keys=['region'],  # we want to correct for this
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo']) 

# with three n_layer conditions
n_layer_list = [1,2,3]

for n_layers in n_layer_list:
    print(f'##### {n_layers} #####')
    # setup
    vae = scvi.model.SCVI(bdata, n_hidden = 128, n_latent = 50, n_layers = n_layers, dispersion = 'gene-batch')
    vae.view_anndata_setup(bdata)
    # train
    vae.train(max_epochs=400)
    # save trained model
    vae.save(f"/nfs/team205/heart/anndata_objects/Foetal/scVI/models/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-{str(n_layers)}/",
             overwrite=True)
    # save latent space
    latent = sc.AnnData(vae.get_latent_representation(),
                    obs=bdata.obs.copy())
    # drop all the obs columns, for simplicity
    latent.obs = latent.obs.drop(columns=latent.obs.columns, axis=1)
    latent.write(f'/nfs/team205/heart/anndata_objects/Foetal/scVI/latent_variables/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-{str(n_layers)}.h5ad')
    # Convergency plot
    vae.history['elbo_train']
    x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
    plt.plot(x, vae.history['elbo_train'], label="train")
    plt.xlabel('epoch')
    plt.ylabel('elbo_train')
    plt.show()
    
    del vae
    # free up GPU
    gc.collect()
    torch.cuda.empty_cache()
    print('')
```

Example 17 (unknown):
```unknown
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
```

Example 18 (python):
```python
# Setup anndata for scVI
bdata = adata.copy()
scvi.model.SCVI.setup_anndata(bdata, 
                              # layer="counts", 
                              batch_key="region", # we want to correct for this 
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

# with three n_layer conditions
n_layer_list = [1,2,3]

for n_layers in n_layer_list:
    print(f'##### {n_layers} #####')
    # setup
    vae = scvi.model.SCVI(bdata, n_hidden = 128, n_latent = 50, n_layers = n_layers, dispersion = 'gene-batch')
    vae.view_anndata_setup(bdata)
    # train
    vae.train(max_epochs=400)
    # save trained model
    vae.save(f"/nfs/team205/heart/anndata_objects/Foetal/scVI/models/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-region_n-layers-{str(n_layers)}/",
             overwrite=True)
    # save latent space
    latent = sc.AnnData(vae.get_latent_representation(),
                    obs=bdata.obs.copy())
    # drop all the obs columns, for simplicity
    latent.obs = latent.obs.drop(columns=latent.obs.columns, axis=1)
    latent.write(f'/nfs/team205/heart/anndata_objects/Foetal/scVI/latent_variables/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-region_n-layers-{str(n_layers)}.h5ad')
    # Convergency plot
    vae.history['elbo_train']
    x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
    plt.plot(x, vae.history['elbo_train'], label="train")
    plt.xlabel('epoch')
    plt.ylabel('elbo_train')
    plt.show()
    
    del vae
    # free up GPU
    gc.collect()
    torch.cuda.empty_cache()
    print('')
```

Example 19 (python):
```python
# Setup anndata for scVI
bdata = adata.copy()
scvi.model.SCVI.setup_anndata(bdata, 
                              # layer="counts", 
                              batch_key="donor", # we want to correct for this 
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

# with three n_layer conditions
n_layer_list = [1,2,3]

for n_layers in n_layer_list:
    print(f'##### {n_layers} #####')
    # setup
    vae = scvi.model.SCVI(bdata, n_hidden = 128, n_latent = 50, n_layers = n_layers, dispersion = 'gene-batch')
    vae.view_anndata_setup(bdata)
    # train
    vae.train(max_epochs=400)
    # save trained model
    vae.save(f"/nfs/team205/heart/anndata_objects/Foetal/scVI/models/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor_n-layers-{str(n_layers)}/",
             overwrite=True)
    # save latent space
    latent = sc.AnnData(vae.get_latent_representation(),
                    obs=bdata.obs.copy())
    # drop all the obs columns, for simplicity
    latent.obs = latent.obs.drop(columns=latent.obs.columns, axis=1)
    latent.write(f'/nfs/team205/heart/anndata_objects/Foetal/scVI/latent_variables/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor_n-layers-{str(n_layers)}.h5ad')
    # Convergency plot
    vae.history['elbo_train']
    x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
    plt.plot(x, vae.history['elbo_train'], label="train")
    plt.xlabel('epoch')
    plt.ylabel('elbo_train')
    plt.show()
    
    del vae
    # free up GPU
    gc.collect()
    torch.cuda.empty_cache()
    print('')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_Glia.html

**Contents:**
- Variables¶
- Read in data¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 1 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
# import session_info
# session_info.show()
```

Example 3 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 4 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 5 (unknown):
```unknown
!ls /lustre/scratch126/cellgen/team205/kk18/xenium/objects/foetal/subsets
```

Example 6 (unknown):
```unknown
ls: cannot access '/lustre/scratch126/cellgen/team205/kk18/xenium/objects/foetal/subsets': No such file or directory
```

Example 7 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'Glia'
```

Example 8 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 9 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 10 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 11 (unknown):
```unknown
AnnData object with n_obs × n_vars = 6976 × 4699
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 12 (python):
```python
adata.X.data[:5]
```

Example 13 (unknown):
```unknown
array([3.036935, 3.036935, 3.036935, 3.705799, 3.036935], dtype=float32)
```

Example 14 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 15 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 16 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 17 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 18 (unknown):
```unknown
CPU times: user 4.52 s, sys: 75.7 ms, total: 4.6 s
Wall time: 4.78 s
```

Example 19 (python):
```python
# markers for fine-grained cell types
markers = {
    "astrocytes": ["GFAP", "S100B", "ALDH1L1"],
    "oligodendrocytes": ["OLIG2", "MBP", "PDGFRA"],
    "microglia": ["AIF1"],  # IBA1 protein is encoded by the AIF1 gene
    "schwann_cells": ["SOX10", "MPZ", "S100B"],
    "schwann_cell_precursors": ["NGFR", "SOX10", "ERBB3"],
    'Cycling':['MKI67','TOP2A'],
    'Others':['NGF']
}

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]
    
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 20 (unknown):
```unknown
AnnData object with n_obs × n_vars = 6976 × 4699
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1', 'leiden_1.2', 'leiden_1.5', 'leiden_2'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 21 (unknown):
```unknown
resolution_sel = 1
```

Example 22 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 23 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: astrocytes, oligodendrocytes, microglia, etc.
```

Example 24 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 25 (unknown):
```unknown
[3.036935 3.036935 3.036935 3.705799 3.036935]
```

Example 26 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 27 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 28 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'Glia',
    '1':'unassigned',
    '2':'Glia',
    '3':'Glia',
    '4':'Glia',
    '5':'Glia',
    '6':'Glia',
    '7':'Glia',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 29 (python):
```python
/tmp/ipykernel_4110952/2206290592.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 30 (unknown):
```unknown
tmp_annotation
Glia          5708
unassigned    1268
Name: count, dtype: int64
```

Example 31 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 32 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['Glia'])]
```

Example 33 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 34 (unknown):
```unknown
AnnData object with n_obs × n_vars = 5708 × 4699
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 35 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 36 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 5708 × 4233
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 37 (python):
```python
'''
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
'''
```

Example 38 (python):
```python
"\n# remove cell cycle genes\ncell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',\n                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',\n                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',\n                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',\n                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',\n                'NEK2','G2E3','GAS2L3','CBX5','CENPA']\nmask = [x not in cell_cycle_genes for x in bdata.var_names]\nbdata = bdata[:,mask]\nbdata.shape\n"
```

Example 39 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 40 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 41 (unknown):
```unknown
number of hvgs: 738
```

Example 42 (python):
```python
2025-06-12 09:34:41,633 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-12 09:34:43,290 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-12 09:34:43,307 - harmonypy - INFO - Iteration 1 of 10
2025-06-12 09:34:43,925 - harmonypy - INFO - Iteration 2 of 10
2025-06-12 09:34:44,533 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 43 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 44 (unknown):
```unknown
CPU times: user 7.57 s, sys: 120 ms, total: 7.69 s
Wall time: 7.71 s
```

Example 45 (python):
```python
markers = {
    "astrocytes": ["GFAP", "S100B", "ALDH1L1"],
    "oligodendrocytes": ["OLIG2", "MBP", "PDGFRA"],
    "microglia": ["AIF1"],  # IBA1 protein is encoded by the AIF1 gene
    "schwann_cells": ["SOX10", "MPZ", "S100B"],
    "schwann_cell_precursors": [
                                "PLS3",'SLITRK6','IL1RAPL2'
                               ],
    "ependymal cells":[
                    "FOXJ1",  # Forkhead box J1
                    "S100B",  # S100 Calcium Binding Protein B
                    "VIM",    # Vimentin
                    "PROM1",  # Prominin-1 (CD133)
                    "CDH1",   # Cadherin 1 (E-cadherin)
                    "EPCAM"   # Epithelial Cell Adhesion Molecule
    ],
    'Cycling':['MKI67','TOP2A'],
    'Others':['NGF'],
    'Neuronal':['NEFL','RBFOX3']
}
genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 46 (unknown):
```unknown
sub_resolution_sel = 0.4
```

Example 47 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 48 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: astrocytes, oligodendrocytes, microglia, etc.
```

Example 49 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 50 (unknown):
```unknown
[2.439362  1.8298357 2.439362  1.8298357 2.439362 ]
```

Example 51 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 52 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=['celltypist_midmod2fine', 'conf_score_midmod2fine'],
                wspace=0.7)
```

Example 53 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'SchwannCellPrecursors',
    '1':'SchwannCells',
    '2':'SchwannCellsCycling',
    '3':'SchwannCells_DoubletsWithNeurons',
    '4':'?EpendymalCells',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 54 (python):
```python
/tmp/ipykernel_4110952/1316203814.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 55 (unknown):
```unknown
fine_grain_manual
SchwannCellPrecursors               2202
SchwannCells                        2036
SchwannCellsCycling                  871
SchwannCells_DoubletsWithNeurons     370
?EpendymalCells                      229
Name: count, dtype: int64
```

Example 56 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 57 (python):
```python
sc.tl.dendrogram(adata_sub,groupby='fine_grain_manual')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 58 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: SchwannCellPrecursors, SchwannCells, SchwannCellsCycling, etc.
var_group_labels: astrocytes, oligodendrocytes, microglia, etc.
```

Example 59 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 60 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 61 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
                  spot_size=60,vmax='p100')
```

Example 62 (python):
```python
/tmp/ipykernel_4110952/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 63 (python):
```python
/tmp/ipykernel_4110952/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 64 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=80,vmax='p100')
```

Example 65 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 66 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 67 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 68 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 69 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 70 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 71 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 72 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 73 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 74 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 75 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 76 (python):
```python
/tmp/ipykernel_4110952/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 77 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 78 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_Glia_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_BloodVesselEC.html

**Contents:**
- Variables¶
- Read in data¶
- Markers¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 0 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-09 22:01
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'BloodVesselEndothelialCells'
```

Example 10 (unknown):
```unknown
figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 20055 × 4950
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([3.0598898, 3.0598898, 3.0598898, 3.0598898, 3.0598898],
      dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 16.9 s, sys: 190 ms, total: 17.1 s
Wall time: 17.1 s
```

Example 21 (python):
```python
# read in markers identified using single-nucleus data
markers_df = pd.read_csv(f'/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_{celltype}_finegrain_markers.csv')

mask1 = markers_df['group_mean']>1
mask2 = markers_df['logfoldchanges']>1
markers_df = markers_df[mask1&mask2]

markers_df
```

Example 22 (python):
```python
markers = {}
n_top = 15
for c in set(markers_df['group']):
    markers_df_sub = markers_df[markers_df['group']==c]
    markers_df_sub.sort_values('logfoldchanges',ascending=False)
    markers[c]=list(markers_df_sub[:n_top]['names'])

# manually add genes
markers['Cycling'] = ['MKI67','TOP2A'] 

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in list(adata.var_names))&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in list(adata.var_names)]
len(genes)
```

Example 23 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",color=genes, size=10,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 24 (unknown):
```unknown
resolution_sel = 0.6
```

Example 25 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              markers_others, 
              groupby=f'leiden_{str(resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 26 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 27 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 28 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CoronaryCapillaryEndothelialCells, CoronaryArterialEndothelialCells, GreatVesselVenousEndothelialCells, etc.
```

Example 29 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 30 (unknown):
```unknown
[3.0598898 3.0598898 3.0598898 3.0598898 3.0598898]
```

Example 31 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 32 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 33 (unknown):
```unknown
'BloodVesselEndothelialCells'
```

Example 34 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'unassigned',
    '1':'BloodVesselEndothelialCells',
    '2':'BloodVesselEndothelialCells',
    '3':'BloodVesselEndothelialCells',
    '4':'BloodVesselEndothelialCells',
    '5':'?ThyroidCells',
    '6':'BloodVesselEndothelialCells',
    '7':'BloodVesselEndothelialCells',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 35 (python):
```python
/tmp/ipykernel_68424/4049359585.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 36 (unknown):
```unknown
tmp_annotation
BloodVesselEndothelialCells    14065
unassigned                      5199
?ThyroidCells                    791
Name: count, dtype: int64
```

Example 37 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 38 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['BloodVesselEndothelialCells'])]
```

Example 39 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 40 (unknown):
```unknown
AnnData object with n_obs × n_vars = 14065 × 4950
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.6', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 41 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 42 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 14065 × 4477
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.6', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 43 (python):
```python
'''
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
'''
```

Example 44 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 45 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 46 (unknown):
```unknown
number of hvgs: 678
```

Example 47 (python):
```python
2025-06-09 22:05:14,014 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-09 22:05:16,262 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-09 22:05:16,351 - harmonypy - INFO - Iteration 1 of 10
2025-06-09 22:05:18,155 - harmonypy - INFO - Iteration 2 of 10
2025-06-09 22:05:19,990 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 48 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 49 (unknown):
```unknown
CPU times: user 22.4 s, sys: 190 ms, total: 22.6 s
Wall time: 22.7 s
```

Example 50 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",size=10,
                color=genes,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 51 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=["conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 52 (python):
```python
# umap per celltype to highlight
group_col = 'celltypist_midmod2fine'
groups_to_plot = list(set(adata_sub.obs[group_col]))

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,8))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                    color=[group_col], groups=grp, 
               size=10, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 53 (unknown):
```unknown
sub_resolution_sel = 2
```

Example 54 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              markers_others, 
              groupby=f'leiden_{str(sub_resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 55 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 56 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 57 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CoronaryCapillaryEndothelialCells, CoronaryArterialEndothelialCells, GreatVesselVenousEndothelialCells, etc.
```

Example 58 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 59 (unknown):
```unknown
[2.8347206 2.8347206 2.8347206 3.893389  2.8347206]
```

Example 60 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
```

Example 61 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 62 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'CoronaryCapillaryEndothelialCells',
    '1':'CoronaryCapillaryEndothelialCellsCycling',
    '2':'GreatVesselVenousEndothelialCells',
    '3':'CoronaryCapillaryEndothelialCellsNOTCHpos',
    '4':'CoronaryCapillaryEndothelialCells',
    '5':'CoronaryCapillaryEndothelialCells',
    '6':'CoronaryVenousEndothelialCells',
    '7':'CoronaryCapillaryEndothelialCells',
    '8':'CoronaryCapillaryEndothelialCells',
    '9':'CoronaryVenousEndothelialCells',
    '10':'CoronaryCapillaryEndothelialCellsNOTCHpos',
    '11':'CoronaryCapillaryEndothelialCells',
    '12':'CoronaryArterialEndothelialCells',
    '13':'CoronaryCapillaryEndothelialCells',
    '14':'GreatVesselArterialEndothelialCells',
    '15':'CoronaryCapillaryEndothelialCells',
    '16':'CoronaryCapillaryEndothelialCells',
    '17':'CoronaryCapillaryEndothelialCells',
    '18':'CoronaryCapillaryEndothelialCells',
    '19':'CoronaryCapillaryEndothelialCells_DoubletsWithEryth',
    '20':'CoronaryCapillaryEndothelialCells',
    '21':'CoronaryCapillaryEndothelialCellsCycling',
    '22':'CoronaryCapillaryEndothelialCells',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 63 (python):
```python
/tmp/ipykernel_68424/23694716.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 64 (unknown):
```unknown
fine_grain_manual
CoronaryCapillaryEndothelialCells                      7259
CoronaryCapillaryEndothelialCellsNOTCHpos              1579
CoronaryVenousEndothelialCells                         1493
CoronaryCapillaryEndothelialCellsCycling               1414
GreatVesselVenousEndothelialCells                      1145
CoronaryArterialEndothelialCells                        504
GreatVesselArterialEndothelialCells                     472
CoronaryCapillaryEndothelialCells_DoubletsWithEryth     199
Name: count, dtype: int64
```

Example 65 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 66 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 67 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 68 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=60,vmax='p100')
```

Example 69 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 70 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 71 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 72 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 73 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 74 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 75 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 76 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 77 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 78 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 79 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 80 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 81 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 82 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 83 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 84 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 85 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 86 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 87 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 88 (python):
```python
/tmp/ipykernel_68424/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 89 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 90 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_BloodVesselEndothelialCells_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Visium/Visium_Intagration-Annotation/Visium_integration_no4_plots-each-annotation.html

**Contents:**
- Functions¶
- Read in anndata¶
- Modify annotation¶
- Plot on visium sections¶

**Examples:**

Example 1 (python):
```python
import sys
import scanpy as sc
import anndata
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt 
import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 
import seaborn as sns

import os
```

Example 2 (python):
```python
sc.settings.set_figure_params(dpi=80,dpi_save=300)
```

Example 3 (unknown):
```unknown
figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk'
```

Example 4 (python):
```python
# This function selects the data for multiple slides from the spatial anndata object.
# Modified `select_slide` in cell2loc for multiple slides

# @param adata: anndata object with multiple spatial experiments
# @param s: list of selected slides
# @param s_col: column in adata.obs listing experiment name for each location

def select_multislide(adata, s, s_col='sample'):

    slides = adata[adata.obs[s_col].isin(s), :]
    s_keys = list(slides.uns['spatial'].keys())
    
    uns_dict = {}
    for ss in s:
        s_spatial=np.array(s_keys)[[ss in k for k in s_keys]][0]
        uns_dict[s_spatial]=slides.uns['spatial'][s_spatial]
    
    slides.uns['spatial'] = uns_dict

    return slides
```

Example 5 (python):
```python
annot = pd.read_csv('/nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_spot-annotation.csv')
annot.set_index('spot_id',inplace=True)
set(annot['final'])
```

Example 6 (unknown):
```unknown
{'AV ring',
 'AV valves',
 'AVnode',
 'Adventitia - Coronary',
 'Adventitia - GV',
 'Aortic valve',
 'Atrium - Left',
 'Atrium - Right',
 'Coronary vessel',
 'Ductus arteriosus',
 'Endocardial cusion',
 'Endocardium - Atrial',
 'Endocardium - Ventricular',
 'Epicardium',
 'Great vessel',
 'LN',
 'SAnode',
 'VCS - Distal',
 'VCS - Proximal',
 'Valve apparatus',
 'Ventricle - Compact - Left',
 'Ventricle - Compact - Right',
 'Ventricle - Trabeculated - Left',
 'Ventricle - Trabeculated - Right'}
```

Example 7 (python):
```python
# the anndata has "gene expression" in .X
# cell2location output is in .obsm['q05_cell_abundance_w_sf']
# kNN graph for UMAP/clustering was generated using cell2location output
adata_vis = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_raw.h5ad')

# modify annotations
annotation_edit_dict = {
   'AV valves':'Valves',
    'Aortic valve':'Valves',
    'Valve apparatus':'Valves',
    'Atrium - Left':'Atrium',
     'Atrium - Right':'Atrium',
    'Ventricle - Compact - Left':'Ventricle - Compact',
    'Ventricle - Compact - Right':'Ventricle - Compact',
    'Ventricle - Trabeculated - Left':'Ventricle - Trabeculated',
    'Ventricle - Trabeculated - Right':'Ventricle - Trabeculated',
}
adata_vis.obs['annotation_final_mod']=adata_vis.obs['annotation_final'].astype('str').copy()
adata_vis.obs.replace({'annotation_final_mod':annotation_edit_dict}, inplace=True)

# set palette and categorie order
AnnotationPalette={ 
    'Atrium':'#eac075',
        'Ventricle - Compact':'#f1acfa',
     'Ventricle - Trabeculated':'#f09951',
        'SAnode':'#8A2BE2',
        'AVnode':'#062b4a',
    'VCS - Proximal':'#FFFF00',
        'VCS - Distal':'#7FFFD4',
        'Epicardium':'#01ccc8',
        'Endocardium - Atrial':'#DC143C',
        'Endocardium - Ventricular':'#f53527',
        'Endocardial cusion':'#ff7e97',
        'Great vessel':'#ff9b6e',
    'Ductus arteriosus':'#8a6800',
        'Coronary vessel':'#206601',
        'Adventitia - Coronary':'#CAFF70',
     'Adventitia - GV':'#005aa0',
        'AV ring':'#e478ff',
    'Valves':'#3300FF',
    'LN':'#9088ff',
}
adata_vis.obs['annotation_final_mod'] = adata_vis.obs['annotation_final_mod'].astype('category')
adata_vis.obs['annotation_final_mod'] = adata_vis.obs['annotation_final_mod'].cat.reorder_categories(AnnotationPalette.keys())

adata_vis
```

Example 8 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:1840: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 39223 × 33562
    obs: 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'cell2loc-map_group', 'JC_edit', 'sample_for_cell2loc', 'week', 'leiden', 'region_cluster', 'AtrialCardiomyocytesLeft', 'AtrialCardiomyocytesRight', 'VentricularCardiomyocytesLeftCompact', 'VentricularCardiomyocytesRightCompact', 'VentricularCardiomyocytesLeftTrabeculated', 'VentricularCardiomyocytesRightTrabeculated', 'SinoatrialNodeCardiomyocytes', 'AtrioventricularNodeCardiomyocytes', 'VentricularConductionSystemProximal', 'VentricularConductionSystemDistal', 'GreatVesselAdventitialFibroblasts', 'CoronaryVesselAdventitialFibroblasts', 'MyocardialInterstitialFibroblasts1', 'MyocardialInterstitialFibroblasts2', 'Myofibroblasts', 'LymphNodeFibroblasticReticularCells', 'ValveInterstitialCells', 'GreatVesselSmoothMuscleCells', 'CoronarySmoothMuscleCells', 'CoronaryPericytes', 'GreatVesselArterialEndothelialCells', 'GreatVesselVenousEndothelialCells', 'CoronaryArterialEndothelialCells', 'CoronaryVenousEndothelialCells', 'CoronaryCapillaryEndothelialCells', 'EndocardialCells', 'EndocardialCushionCells', 'ValveEndothelialCells', 'LymphaticEndothelialCells', 'MesothelialEpicardialCells', 'EpicardiumDerivedCells', 'NeuronPrecursors', 'ChromaffinCells', 'SympatheticNeurons', 'ParaympatheticNeurons', 'SchwannCellPrecursors', 'SchwannCells', 'MonocytesMPOpos', 'Monocytes', 'MonocyteDerivedCells', 'MacrophagesCX3CR1pos', 'MacrophagesTIMD4pos', 'MacrophagesLYVE1pos', 'MacrophagesATF3pos', 'DendriticCellsType1', 'DendriticCellsMature', 'PlasmacytoidDendriticCells', 'MastCells', 'Megakaryocytes', 'TCellsCD4pos', 'TCellsCD8pos', 'TregsCD4pos', 'ProBCells', 'BCells', 'BCellsMS4A1pos', 'NaturalKillerCells', 'InnateLymphoidCells', 'DuctusArteriosusSmoothMuscleCells', 'AtrialCardiomyocytesLeft_minmax', 'AtrialCardiomyocytesRight_minmax', 'VentricularCardiomyocytesLeftCompact_minmax', 'VentricularCardiomyocytesRightCompact_minmax', 'VentricularCardiomyocytesLeftTrabeculated_minmax', 'VentricularCardiomyocytesRightTrabeculated_minmax', 'SinoatrialNodeCardiomyocytes_minmax', 'AtrioventricularNodeCardiomyocytes_minmax', 'VentricularConductionSystemProximal_minmax', 'VentricularConductionSystemDistal_minmax', 'GreatVesselAdventitialFibroblasts_minmax', 'CoronaryVesselAdventitialFibroblasts_minmax', 'MyocardialInterstitialFibroblasts1_minmax', 'MyocardialInterstitialFibroblasts2_minmax', 'Myofibroblasts_minmax', 'LymphNodeFibroblasticReticularCells_minmax', 'ValveInterstitialCells_minmax', 'GreatVesselSmoothMuscleCells_minmax', 'CoronarySmoothMuscleCells_minmax', 'CoronaryPericytes_minmax', 'GreatVesselArterialEndothelialCells_minmax', 'GreatVesselVenousEndothelialCells_minmax', 'CoronaryArterialEndothelialCells_minmax', 'CoronaryVenousEndothelialCells_minmax', 'CoronaryCapillaryEndothelialCells_minmax', 'EndocardialCells_minmax', 'EndocardialCushionCells_minmax', 'ValveEndothelialCells_minmax', 'LymphaticEndothelialCells_minmax', 'MesothelialEpicardialCells_minmax', 'EpicardiumDerivedCells_minmax', 'NeuronPrecursors_minmax', 'ChromaffinCells_minmax', 'SympatheticNeurons_minmax', 'ParaympatheticNeurons_minmax', 'SchwannCellPrecursors_minmax', 'SchwannCells_minmax', 'MonocytesMPOpos_minmax', 'Monocytes_minmax', 'MonocyteDerivedCells_minmax', 'MacrophagesCX3CR1pos_minmax', 'MacrophagesTIMD4pos_minmax', 'MacrophagesLYVE1pos_minmax', 'MacrophagesATF3pos_minmax', 'DendriticCellsType1_minmax', 'DendriticCellsMature_minmax', 'PlasmacytoidDendriticCells_minmax', 'MastCells_minmax', 'Megakaryocytes_minmax', 'TCellsCD4pos_minmax', 'TCellsCD8pos_minmax', 'TregsCD4pos_minmax', 'ProBCells_minmax', 'BCells_minmax', 'BCellsMS4A1pos_minmax', 'NaturalKillerCells_minmax', 'InnateLymphoidCells_minmax', 'DuctusArteriosusSmoothMuscleCells_minmax', 'annotation', 'annotation_final', 'annotation_final_coarse', 'annotation_final_mod'
    var: 'gene_ids'
    uns: 'JC_edit_colors', 'annotation_colors', 'annotation_final_colors', 'cell2loc-map_group_colors', 'leiden', 'neighbors', 'region_cluster_colors', 'sample_for_cell2loc_colors', 'umap'
    obsm: 'MT', 'X_umap', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q05_cell_abundance_w_sf_ndarray', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
    obsp: 'connectivities', 'distances'
```

Example 10 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['annotation_final_mod'], size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False, palette=AnnotationPalette,
               show=False
              )
    plt.savefig(f"{figdir}/UMAP_Visium_annotations.pdf", bbox_inches="tight",dpi=300)
```

Example 11 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 12 (python):
```python
# need to read in each object to plot visium section...(as far as i know)
adata_ffpe = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-FFPE_foetal_raw.h5ad')
adata_ffpe.obs['sample_for_cell2loc'] = adata_ffpe.obs['sample'].copy()
adata_ffpe.obs['cell2loc-map_group'] = 'FFPE_16PCW'
adata_ffpe = adata_ffpe[adata_ffpe.obs['JC_edit'].isin(['Cavity'])==False]

# add annotation
adata_ffpe.obs['annotation_final_mod'] = adata_vis.obs['annotation_final_mod'].reindex(adata_ffpe.obs_names)
```

Example 13 (python):
```python
/tmp/ipykernel_58671/3263657043.py:8: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  adata_ffpe.obs['annotation_final_mod'] = adata_vis.obs['annotation_final_mod'].reindex(adata_ffpe.obs_names)
```

Example 14 (python):
```python
slide_id = 'BHF_F_Hea13295831'
slide = select_multislide(adata_ffpe, [slide_id])

with mpl.rc_context({'figure.figsize': [4.5, 4],
                    'axes.titlesize':14,}):

    sc.pl.spatial(slide,
                  color=['annotation_final_mod'], 
                  size=0,img_key='hires',alpha_img=1,title='',legend_loc=None,
                  show=False
                                   )
    plt.savefig(f"{figdir}/visium_HE_{slide_id}.pdf", bbox_inches="tight",dpi=300)
    
    sc.pl.spatial(slide,
                  color=['annotation_final_mod'], 
                  size=1.2,img_key='hires',alpha_img=0.3, palette=AnnotationPalette,
                  show=False
                 )
    plt.savefig(f"{figdir}/visium_annotation_{slide_id}.pdf", bbox_inches="tight",dpi=300)
```

Example 15 (unknown):
```unknown
/tmp/ipykernel_58671/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 16 (python):
```python
slide_id = 'BHF_F_Hea13295831'
slide = select_multislide(adata_ffpe, [slide_id])

with mpl.rc_context({'figure.figsize': [4.5, 4],
                    'axes.titlesize':14,}):

    sc.pl.spatial(slide,
                  color=['annotation_final_mod'], 
                  size=0,img_key='hires',alpha_img=1,title='',legend_loc=None,
                  crop_coord = [8000,15500,7000,14000],show=False
                 )
    plt.savefig(f"{figdir}/visium_cropped_HE_{slide_id}.pdf", bbox_inches="tight",dpi=300)
    
    sc.pl.spatial(slide,
                  color=['annotation_final_mod'], 
                  size=1.2,img_key='hires',alpha_img=0.3, palette=AnnotationPalette,
                  crop_coord = [8000,15500,7000,14000],show=False
                 )
    plt.savefig(f"{figdir}/visium_cropped_annotation_{slide_id}.pdf", bbox_inches="tight",dpi=300)
```

Example 17 (unknown):
```unknown
/tmp/ipykernel_58671/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Leukocytes/No5_immune-collect-annotations.html

**Contents:**
- Import modules¶
- Read in immune raw data¶
- Read in myeloid and lymphoid objects for the annotation¶
- Add annotation¶
- new_fine_grain¶
- new_mid_grain¶
- Set category¶
- Save¶
- Markers¶

41881 rows × 53 columns

**Examples:**

Example 1 (python):
```python
import anndata
import numpy as np
import pandas as pd
import scanpy as sc

import matplotlib.pyplot as plt
import seaborn as sns

import celltypist
from celltypist import models

import session_info
```

Example 2 (python):
```python
sc.settings.set_figure_params(dpi=120, color_map = 'RdPu',)
```

Example 3 (unknown):
```unknown
session_info.show()
```

Example 4 (python):
```python
-----
anndata             0.8.0
celltypist          0.1.9
matplotlib          3.5.2
numpy               1.21.5
pandas              1.3.5
scanpy              1.8.2
seaborn             0.11.1
session_info        1.0.0
-----
```

Example 5 (python):
```python
PIL                 9.1.1
asciitree           NA
backcall            0.2.0
beta_ufunc          NA
binom_ufunc         NA
brotli              NA
cached_property     1.5.1
cairo               1.20.0
certifi             2020.12.05
cffi                1.14.4
chardet             3.0.4
charset_normalizer  2.0.10
cloudpickle         1.6.0
colorama            0.4.4
cycler              0.10.0
cython_runtime      NA
cytoolz             0.11.2
dask                2022.01.0
dateutil            2.8.1
decorator           4.4.2
defusedxml          0.6.0
fasteners           0.17.3
fsspec              2022.01.0
google              NA
h5py                3.1.0
idna                2.10
igraph              0.10.2
importlib_metadata  1.7.0
ipykernel           5.4.2
ipython_genutils    0.2.0
ipywidgets          7.6.3
jedi                0.17.2
jinja2              3.1.2
joblib              1.0.0
kiwisolver          1.3.1
leidenalg           0.9.0
llvmlite            0.35.0
louvain             0.7.0
markupsafe          2.1.1
mpl_toolkits        NA
msgpack             1.0.3
natsort             7.1.0
nbinom_ufunc        NA
numba               0.52.0
numcodecs           0.9.1
numexpr             2.7.2
packaging           21.3
parso               0.7.1
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
plotly              5.10.0
prompt_toolkit      3.0.10
psutil              5.9.0
ptyprocess          0.7.0
pyarrow             9.0.0
pygments            2.13.0
pyparsing           2.4.7
pytz                2020.5
requests            2.27.1
scipy               1.7.3
setuptools_scm      NA
sinfo               0.3.1
six                 1.14.0
sklearn             1.0.2
socks               1.7.1
sphinxcontrib       NA
statsmodels         0.12.1
storemagic          NA
tables              3.6.1
tblib               1.7.0
texttable           1.6.3
threadpoolctl       2.1.0
tlz                 0.11.2
toolz               0.11.2
tornado             6.1
traitlets           5.0.5
typing_extensions   NA
urllib3             1.26.9
wcwidth             0.2.5
yaml                5.4.1
zarr                2.11.3
zipp                NA
zmq                 21.0.1
zope                NA
```

Example 6 (unknown):
```unknown
-----
IPython             7.19.0
jupyter_client      6.1.11
jupyter_core        4.7.0
notebook            6.2.0
-----
Python 3.7.9 | packaged by conda-forge | (default, Dec  9 2020, 21:08:20) [GCC 9.3.0]
Linux-4.15.0-158-generic-x86_64-with-debian-bullseye-sid
-----
Session information updated at 2023-02-21 09:51
```

Example 7 (unknown):
```unknown
!ls /nfs/team205/heart/anndata_objects/Foetal/Immune/
```

Example 8 (unknown):
```unknown
C97_index.csv
RNA_foetal_raw_immune_16Feb2023.h5ad
RNA_foetal_raw_Lymphoid_16Feb2023.h5ad
RNA_foetal_raw_Lymphoid_16Feb2023.obs.csv
RNA_foetal_raw_Myeloid_16Feb2023.h5ad
RNA_foetal_raw_Myeloid_16Feb2023.obs.csv
```

Example 9 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_immune_16Feb2023.h5ad')
adata
```

Example 10 (unknown):
```unknown
AnnData object with n_obs × n_vars = 41881 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2'
    var: 'gene_name_scRNA-0', 'gene_id'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 11 (python):
```python
adata.X.data[:10]
```

Example 12 (unknown):
```unknown
array([1., 2., 1., 1., 1., 2., 2., 5., 2., 2.], dtype=float32)
```

Example 13 (python):
```python
sc.pl.umap(adata, color=['cell_type2'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 14 (unknown):
```unknown
!ls /nfs/team205/heart/anndata_objects/Foetal/Immune/
```

Example 15 (python):
```python
lymph = pd.read_csv('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Lymphoid_16Feb2023.obs.csv',index_col=0)
lymph.head()
```

Example 16 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3418: DtypeWarning: Columns (37) have mixed types.Specify dtype option on import or set low_memory=False.
  exec(code_obj, self.user_global_ns, self.user_ns)
```

Example 17 (python):
```python
myelo = pd.read_csv('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Myeloid_16Feb2023.obs.csv',index_col=0)
myelo.head()
```

Example 18 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3418: DtypeWarning: Columns (37) have mixed types.Specify dtype option on import or set low_memory=False.
  exec(code_obj, self.user_global_ns, self.user_ns)
```

Example 19 (python):
```python
adata.obs['new_fine_grain'] = adata.obs['cell_type2'].astype('str')
adata.obs.loc[lymph.index,'new_fine_grain'] = lymph['cell_type3'].astype('str')
adata.obs.loc[myelo.index,'new_fine_grain'] = myelo['cell_type3'].astype('str')
adata.obs['new_fine_grain'].value_counts()
```

Example 20 (javascript):
```javascript
MP_LYVE1+            9748
CD4+T                5206
B_MS4A1+             3722
NK                   2437
CD8+T                2121
CD4+Treg             1940
MP_LYVE1+ATF3+       1844
B                    1666
MP_LYVE1+_cycling    1650
MP_CX3CR1+           1648
ILC                  1639
T_cycling             912
Mono                  900
Mast cell             866
Bpro                  850
B_cycling             843
Mono-derived          661
DC1                   609
Plasmacytoid DC       608
Doublet               583
MP_TIMD4+             470
Mono_MPO+             414
Megakaryocyte         360
DC_mature             184
Name: new_fine_grain, dtype: int64
```

Example 21 (python):
```python
sc.pl.umap(adata, color=['new_fine_grain'], size=5, legend_fontsize=7, frameon=False, components='all', wspace=0.6)
```

Example 22 (unknown):
```unknown
... storing 'new_fine_grain' as categorical
```

Example 23 (python):
```python
set(adata.obs['new_fine_grain'])
```

Example 24 (unknown):
```unknown
{'B',
 'B_MS4A1+',
 'B_cycling',
 'Bpro',
 'CD4+T',
 'CD4+Treg',
 'CD8+T',
 'DC1',
 'DC_mature',
 'Doublet',
 'ILC',
 'MP_CX3CR1+',
 'MP_LYVE1+',
 'MP_LYVE1+ATF3+',
 'MP_LYVE1+_cycling',
 'MP_TIMD4+',
 'Mast cell',
 'Megakaryocyte',
 'Mono',
 'Mono-derived',
 'Mono_MPO+',
 'NK',
 'Plasmacytoid DC',
 'T_cycling'}
```

Example 25 (python):
```python
fine2mid = {
    'Mono':'MyeloidCells', 
    'Mono_MPO+':'MyeloidCells', 
    'Mono-derived':'MyeloidCells',
    'MP_CX3CR1+':'MyeloidCells',
    # 'MP_TREM2+':'MyeloidCells', 
    'MP_TIMD4+':'MyeloidCells',
    'MP_LYVE1+':'MyeloidCells',
    # 'MP_LYVE1+JUN+':'MyeloidCells',
    'MP_LYVE1+ATF3+':'MyeloidCells',
    'MP_LYVE1+_cycling':'MyeloidCells',
    'DC1':'MyeloidCells',
    'DC_mature':'MyeloidCells',
    'Plasmacytoid DC':'MyeloidCells',
    'Mast cell':'MyeloidCells',
    'Megakaryocyte':'MyeloidCells',
    'CD4+T':'LymphoidCells',
    'CD4+Treg':'LymphoidCells',
    'CD8+T':'LymphoidCells',
    'NK':'LymphoidCells',
    'ILC':'LymphoidCells',
    'T_cycling':'LymphoidCells',
    'Bpro':'LymphoidCells',
    'B':'LymphoidCells',
    'B_MS4A1+':'LymphoidCells',
    'B_cycling':'LymphoidCells',
    'Doublet':'Doublet',
}

adata.obs['new_mid_grain']=adata.obs['new_fine_grain'].copy()
adata.obs.replace({'new_mid_grain':fine2mid},inplace=True)
pd.crosstab(adata.obs['new_fine_grain'],adata.obs['new_mid_grain'])
```

Example 26 (python):
```python
adata.obs['new_mid_grain']=adata.obs['new_mid_grain'].astype('category')
adata.obs['new_mid_grain'].cat.reorder_categories([
   'MyeloidCells', 
    'LymphoidCells',
    'Doublet',
     ], inplace=True)

adata.obs['new_fine_grain']=adata.obs['new_fine_grain'].astype('category')
adata.obs['new_fine_grain'].cat.reorder_categories(list(fine2mid.keys()), inplace=True)
```

Example 27 (python):
```python
sc.pl.umap(adata, color=['new_fine_grain'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.8)
```

Example 28 (python):
```python
sc.pl.umap(adata, color=['new_fine_grain'], groups='Mono-derived',size=5, legend_fontsize=7, frameon=False, components='all', wspace=0.6)
```

Example 29 (python):
```python
sc.pl.umap(adata, color=['new_mid_grain'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.3)
```

Example 30 (python):
```python
adata.X.data[:10]
```

Example 31 (unknown):
```unknown
array([1., 2., 1., 1., 1., 2., 2., 5., 2., 2.], dtype=float32)
```

Example 32 (unknown):
```unknown
!ls /nfs/team205/heart/anndata_objects/Foetal/Immune
```

Example 33 (unknown):
```unknown
C97_index.csv
RNA_foetal_raw_immune_16Feb2023.h5ad
RNA_foetal_raw_Lymphoid_16Feb2023.h5ad
RNA_foetal_raw_Lymphoid_16Feb2023.obs.csv
RNA_foetal_raw_Myeloid_16Feb2023.h5ad
RNA_foetal_raw_Myeloid_16Feb2023.obs.csv
```

Example 34 (python):
```python
adata.write('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_immune_16Feb2023.h5ad')
adata
```

Example 35 (unknown):
```unknown
AnnData object with n_obs × n_vars = 41881 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2', 'new_fine_grain', 'new_mid_grain'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'cell_type2_colors', 'new_fine_grain_colors', 'new_mid_grain_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 36 (python):
```python
# save .obs
adata.obs.to_csv('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_immune_16Feb2023.obs.csv')
```

Example 37 (unknown):
```unknown
!ls -l  /nfs/team205/heart/anndata_objects/Foetal/Immune
```

Example 38 (unknown):
```unknown
total 1500548
-rw-r--r-- 1 20383 1403    264965 Feb 16 10:37 C97_index.csv
-rw-r--r-- 1 20383 1403 763332444 Feb 17 13:21 RNA_foetal_raw_immune_16Feb2023.h5ad
-rw-r--r-- 1 20383 1403  23704564 Feb 17 13:58 RNA_foetal_raw_immune_16Feb2023.obs.csv
-rw-r--r-- 1 20383 1403 369182732 Feb 17 12:59 RNA_foetal_raw_Lymphoid_16Feb2023.h5ad
-rw-r--r-- 1 20383 1403  12130193 Feb 17 13:15 RNA_foetal_raw_Lymphoid_16Feb2023.obs.csv
-rw-r--r-- 1 20383 1403 358041637 Feb 16 23:33 RNA_foetal_raw_Myeloid_16Feb2023.h5ad
-rw-r--r-- 1 20383 1403   9891132 Feb 16 23:33 RNA_foetal_raw_Myeloid_16Feb2023.obs.csv
```

Example 39 (unknown):
```unknown
# rclone to gdrive
rclone copy /nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_immune_16Feb2023.h5ad \
gdrive:JamesC_Kazumasa/Foetal_Heart/SanjayShinha/toSinhalab/anndata/Immune_16Feb2023
    
rclone copy /nfs/team205/heart/anndata_objects/Foetal/Immune/C97_index.csv \
gdrive:JamesC_Kazumasa/Foetal_Heart/SanjayShinha/toSinhalab/anndata/Immune_16Feb2023
```

Example 40 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_immune_16Feb2023.h5ad')
adata
```

Example 41 (unknown):
```unknown
AnnData object with n_obs × n_vars = 41881 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2', 'new_fine_grain', 'new_mid_grain'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'cell_type2_colors', 'new_fine_grain_colors', 'new_mid_grain_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 42 (python):
```python
adata_lognorm = adata.copy()
sc.pp.normalize_total(adata_lognorm, target_sum=1e4)
sc.pp.log1p(adata_lognorm)
```

Example 43 (python):
```python
markers={
    'Mono':['CCR2','FCN1','MPO'],
    'MP general':['C1QA','C1QB','CD68','MRC1','CD163','LYVE1','FOLR2'],
    'CXCR1+':['CX3CR1','FCGR1A','FCGR3A','C3'],
    'TREM2+':['TREM2','SPP1'],
    'PtdSer-R':['TIMD4','MERTK','AXL','ITGAV'],
    'FOS-JUN':['FOS','JUN'],
    'Collagen':['COL1A1','COL1A2','COL3A1'],
    'DC general':['FLT3','HLA-DPA1','HLA-DPB1','CIITA'],
    'DC1':['ID2','BATF3','CLEC9A'],
    'DC2':['CLEC10A','CD1C'],
    'DC_mature':['CCR7','CD83', 'LY75','LAMP3'],
    'pDC':['IRF8','IRF4','IL3RA'],
      'Mast': ['KIT', 'CPA3','HDC','GATA2'],
    'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA'],
    'cytotoxic': ['PRF1', 'GZMB','NKG7'],
    'NK': ['KLRF1', 'KLRD1','NCAM1',],
    'ILC': ['KIT', 'IL7R','IL18R1','RORC','IL17A'],   
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B'],
     'ProB':['CD34'],
    'B1':['MS4A1','IGHM','IGHD','MZB1'],
    'Gene editing': ['RAG1','RAG2'],
    'Cycling':['MKI67','TOP2A'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

dp = sc.pl.dotplot(adata_lognorm,
              markers, 
              groupby='new_fine_grain',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              return_fig=True
              # swap_axes=True,
             )
dp.add_totals().show()
```

Example 44 (python):
```python
markers={
     'Mono':['CCR2','FCN1','MPO'],
    'Mono-derived':['CLEC10A','CD1C'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163','LYVE1','FOLR2'],
    'CX3CR1+':['CX3CR1','FCGR1A','FCGR3A','C3','P2RY12','SALL1','C3','OLFML3','HTRA1','TREM2',],
    'PtdSer-R':['TIMD4','MERTK','AXL','ITGAV'],
    'ATF3':['ATF3'],
    'DC general':['FLT3','HLA-DPA1','HLA-DPB1','CIITA'],
    'DC1':['ID2','BATF3','CLEC9A'],
    'pDC':['IRF8','IRF4','IL3RA'],
    'Mast': ['KIT', 'CPA3','HDC','GATA2'],
  
    
    'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2'],
    'cytotoxic': ['PRF1', 'GZMB','NKG7'],
    'NK': ['KLRF1', 'KLRD1','NCAM1','FCGR3A','IFNG'],
    'ILC': ['KIT', 'IL7R','IL18R1','RORC','IL17A'],   
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1'],
     'ProB':['CD34'],
    'B1':['CD27','CCR10'],
    'Igs':['IGHM','IGHD'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    'Cycling':['MKI67','TOP2A'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

dp = sc.pl.dotplot(adata_lognorm,
              markers, 
              groupby='new_fine_grain',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              return_fig=True
              # swap_axes=True,
             )
dp.add_totals().show()
```

Example 45 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','TRAC','TRBC1',],
     'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1'],
   
    
    'Mono':['CCR2','CD14','FCGR3A','CX3CR1','FCGR1A','FCN1','TREM2'],
    'MP':['C1QA','C1QB','CD68','CD163','MERTK','LYVE1','IGF1','TIMD4','CX3CR1','DOCK4'],
    'pDC':['IRF8','IRF4','IL3RA'],
     'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'Megakaryocyte':['ITGA2B','MPL','ITGB3',],
    'Mast': ['KIT', 'CPA3','HDC','GATA2'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata_lognorm,
              markers, 
              groupby='cell_type2',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Leukocytes/No4_Lymphoid_post-scVI.html

**Contents:**
- Import modules¶
- Function¶
- Read in data¶
- Log-normalise¶
- Clustering, UMAP¶
  - Deciding resolution¶
- Marker gene expressions¶
- DEG analysis¶
- CellTypist prediction¶
- Annotation¶
- Recover row counts and save¶
- Assign non-cycling cell type labels to "T_cycling" cells¶
- 1) Regressing out cell cycle genes¶
- 2) Train LR model with non-cycling cells (only for non-B cells)¶
- 3) Predict cell states¶
- 4) Check marker expressions¶
- 5) Save assigned list¶
- Celltypist, pan-foetal immune¶
- Check matching with previoius annotation¶

gene expression: normalise + logtransform

**Examples:**

Example 1 (python):
```python
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import matplotlib.pyplot as plt
import anndata


import celltypist
from celltypist import models

import sctk
import os
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
-----
anndata             0.8.0
celltypist          0.1.9
matplotlib          3.5.2
numpy               1.21.5
pandas              1.3.5
scanpy              1.8.2
sctk                NA
session_info        1.0.0
-----
```

Example 4 (python):
```python
PIL                 9.1.1
asciitree           NA
backcall            0.2.0
beta_ufunc          NA
binom_ufunc         NA
brotli              NA
cached_property     1.5.1
cairo               1.20.0
certifi             2020.12.05
cffi                1.14.4
chardet             3.0.4
charset_normalizer  2.0.10
cloudpickle         1.6.0
colorama            0.4.4
cycler              0.10.0
cython_runtime      NA
cytoolz             0.11.2
dask                2022.01.0
dateutil            2.8.1
decorator           4.4.2
defusedxml          0.6.0
fasteners           0.17.3
fsspec              2022.01.0
google              NA
h5py                3.1.0
idna                2.10
igraph              0.10.2
importlib_metadata  1.7.0
ipykernel           5.4.2
ipython_genutils    0.2.0
ipywidgets          7.6.3
jedi                0.17.2
jinja2              3.1.2
joblib              1.0.0
kiwisolver          1.3.1
leidenalg           0.9.0
llvmlite            0.35.0
louvain             0.7.0
markupsafe          2.1.1
mpl_toolkits        NA
msgpack             1.0.3
natsort             7.1.0
nbinom_ufunc        NA
numba               0.52.0
numcodecs           0.9.1
numexpr             2.7.2
numpy_groupies      0.9.13
packaging           21.3
parso               0.7.1
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
plotly              5.10.0
prompt_toolkit      3.0.10
psutil              5.9.0
ptyprocess          0.7.0
pyarrow             9.0.0
pygments            2.13.0
pyparsing           2.4.7
pytz                2020.5
requests            2.27.1
scipy               1.7.3
scvelo              0.2.4
seaborn             0.11.1
setuptools_scm      NA
sinfo               0.3.1
six                 1.14.0
sklearn             1.0.2
socks               1.7.1
sphinxcontrib       NA
statsmodels         0.12.1
storemagic          NA
tables              3.6.1
tblib               1.7.0
texttable           1.6.3
threadpoolctl       2.1.0
tlz                 0.11.2
toolz               0.11.2
tornado             6.1
traitlets           5.0.5
typing_extensions   NA
urllib3             1.26.9
wcwidth             0.2.5
yaml                5.4.1
zarr                2.11.3
zipp                NA
zmq                 21.0.1
zope                NA
```

Example 5 (unknown):
```unknown
-----
IPython             7.19.0
jupyter_client      6.1.11
jupyter_core        4.7.0
notebook            6.2.0
-----
Python 3.7.9 | packaged by conda-forge | (default, Dec  9 2020, 21:08:20) [GCC 9.3.0]
Linux-4.15.0-158-generic-x86_64-with-debian-bullseye-sid
-----
Session information updated at 2023-02-22 12:48
```

Example 6 (python):
```python
sc.settings.set_figure_params(dpi=120, facecolor='white', color_map = 'RdPu',)
```

Example 7 (python):
```python
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# extract rank_genes_groups result 
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

import scanpy as sc
import pandas as pd

def rank_genes_groups_to_df(adata, cell):
    
    dic = adata.uns['rank_genes_groups'] 
    
    df = pd.DataFrame({
        'names' : dic['names'][cell],
        'scores' : dic['scores'][cell],
        'pvals' : dic['pvals'][cell],
        'pvals_adj' : dic['pvals_adj'][cell],
        'logfoldchanges' : dic['logfoldchanges'][cell]
    })
    
    return df
```

Example 8 (unknown):
```unknown
compartment = 'Lymphoid'
```

Example 9 (python):
```python
adata = sc.read_h5ad(f'/home/jovyan/mount/gdrive/Colab/data/scVI/subsets/RNA_foetal_{compartment}_post-scVI_16Feb2023.h5ad')
adata
```

Example 10 (unknown):
```unknown
AnnData object with n_obs × n_vars = 21336 × 28811
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2'
    var: 'gene_name_scRNA-0', 'gene_id', 'n_cells'
    uns: '_scvi_manager_uuid', '_scvi_uuid'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 11 (python):
```python
# normalise and logtransform
# adata.raw = adata
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
```

Example 12 (python):
```python
%%time

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata, min_dist=0.2, spread=1.0, n_components=3)

resolutions = [0.2,0.3,0.4,0.5,0.6,] # 0.7,0.8,0.9,1.0
for res in resolutions:
    print(res)
    sc.tl.leiden(adata, resolution=res, key_added=f'leiden_scVI_{res}')
    sc.pl.umap(adata, color=[f'leiden_scVI_{res}'], size=5, components='all', wspace=0.5)
```

Example 13 (python):
```python
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata, min_dist=0.2, spread=1.0, n_components=3)
sc.tl.leiden(adata, resolution=1, key_added='leiden_scVI')
```

Example 14 (python):
```python
sc.pl.umap(adata, color=['leiden_scVI'], size=5, wspace=0.1, legend_loc='on data', legend_fontsize=10,components='all')
```

Example 15 (python):
```python
sc.pl.umap(adata, color=['region','donor','cell_or_nuclei','kit_10x'], size=5, wspace=0.7)
```

Example 16 (python):
```python
sc.pl.umap(adata, color=['week'], size=3, wspace=0.5)
```

Example 17 (python):
```python
sc.pl.umap(adata, color=['scrublet_score','cluster_scrublet_score','doublet_pval','doublet_bh_pval','pct_counts_mt','pct_counts_ribo'], size=2, wspace=0.2, ncols=6)
```

Example 18 (python):
```python
stress_genes=['CD3E','CD4','CD8A','FOXP3','CD79A','CD79B','RAG1','RAG2','MS4A1','IGHD','TRBC1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
sc.pl.umap(adata, color=stress_genes, size=5, wspace=0.2, ncols=6)
```

Example 19 (python):
```python
# Checking glabal markers
markers = {
    'vCM': ['MYH7', 'MYL2', 'FHL2'],
    'aCM': ['NPPA', 'MYL7', 'MYL4'],
    'FB': ['DCN', 'GCN', 'PDGFRA'],
    'EC': ['VWF', 'PECAM1', 'CDH5'],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby='leiden_scVI')
sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 20 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: vCM, aCM, FB, etc.
```

Example 21 (python):
```python
# lymphocytes markers

markers={
    'B cell': ['CD19', 'CD79A', 'CD79B', 'IGHM', 'IGHG1', 'IGHA1'],
    'T cell': ['CD3E', 'CD3D', 'TRAC', 'CD4', 'CD8A', 'CD8B'],
    'naive': ['CCR7', 'TCF7', 'LEF1', 'SELL'],
    'act': ['IL2','CD69'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2'],
    'cytotoxic': ['PRF1', 'GZMB', 'GZMH', 'NKG7'],
    'trans': ['GZMK', 'TOX'],
    'te': ['TIGIT', 'LAG3', 'PDCD1'],
    'em': ['IL7R', 'RUNX2'],
    'MAIT': ['SLC4A10', 'KLRB1', 'CCR6'],
    'NK': ['KLRF1', 'KLRD1', 'NCAM1', 'FCGR3A'],
    'ILC': ['KIT', 'IL18R1'],
    'cycling': ['MKI67', 'TOP2A', 'UBE2C'],
    'TFs': ['TBX21', 'GATA3', 'RORC', 'BCL6',],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 22 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: B cell, T cell, naive, etc.
```

Example 23 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B','TRAC','TRBC1','TRDC','TRGC1'],
    'naive': ['TCF7', 'LEF1', 'SELL'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2'],
    'cytotoxic': ['PRF1', 'GZMB', 'GZMH', 'NKG7'],
    'NK': ['KLRF1', 'KLRD1', 'NCAM1','FCGR3A','IFNG'],
    'ILC3': ['KIT', 'IL18R1','RORC','IL17A'],
    
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1','IL7R',],
    '':['CCR7','TNFRSF13B',],
    'ProB':['KIT','SPN','CD34'],
    'B1':['CD27','CCR10','MS4A1','SPN'],
    'Plasma': ['CD27','CCR10','CD38','SDC1','JCAIN'],
    'Abs':['IGHM','IGHD', 'IGHG1','IGHG2', 'IGHG3','IGHG4', 'IGHA1','IGHE','IGLC1','IGKC'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    
    
    'Cycling':['MKI67','TOP2A'],

    'TFs': ['TBX21', 'GATA3', 'RORC', 'BCL6',],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 24 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: T cell, naive, CD4T_reg, etc.
```

Example 25 (python):
```python
adata.X.data[:10]
```

Example 26 (python):
```python
sc.tl.rank_genes_groups(adata, 'leiden_scVI', method='t-test')

DEG_dict = {}
for cluster in adata.obs['leiden_scVI'].cat.categories:
    df=rank_genes_groups_to_df(adata, cluster)
    # select genes: significant and up-regulated ones
    df=df[(df['pvals_adj']<0.05)&(df['logfoldchanges']>0)]
    # sort based on the logFC
    df.sort_values('scores',ascending=False,inplace=True)
    DEG_dict[cluster]=list(df[:10]['names'])
    del df

sc.pl.dotplot(adata,
              DEG_dict, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 27 (python):
```python
# load model and predict
panfetal_model = models.Model.load('/nfs/team205/kk18/Analysis/celltypist/models/celltypist_model.Pan_Fetal_Human.pkl')
prediction=celltypist.annotate(adata, model = panfetal_model, majority_voting = True)
```

Example 28 (unknown):
```unknown
🔬 Input data has 21336 cells and 28811 genes
🔗 Matching reference genes in the model
🧬 6669 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
👀 Detected a neighborhood graph in the input object, will run over-clustering on the basis of it
⛓️ Over-clustering input data with resolution set to 15
🗳️ Majority voting the predictions
✅ Majority voting done!
```

Example 29 (unknown):
```unknown
celltypist.dotplot(prediction, use_as_reference = 'leiden_scVI', use_as_prediction = 'predicted_labels')
```

Example 30 (python):
```python
sc.pl.umap(adata, color=['leiden_scVI'], size=5, wspace=0.1, legend_loc='on data', components='all', legend_fontsize=7)
```

Example 31 (python):
```python
sc.pl.umap(adata, color=['2Jan_fine_grain'], size=5, wspace=0.1, legend_loc='on data', components='all', legend_fontsize=7)
```

Example 32 (python):
```python
set(adata.obs['2Jan_fine_grain'])
```

Example 33 (unknown):
```unknown
{'B1Cells',
 'BCells',
 'BProCells',
 'Cardiofibromyocytes',
 'CardiofibromyocytesSecretory',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryVesselSmoothMuscleCells',
 'DC1',
 'DC2',
 'DCsPlasmocytoids',
 'EarlyGreatVesselFLRT2',
 'EarlyGreatVesselHOXB4',
 'EndocardialCells',
 'GVAdFibOCA2',
 'GVAdFibOther',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'InnateLymphoidCells',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'MonocytesMPOpos',
 'MyocIntFibROBO2',
 'NaturalKillerCells',
 'SchwannCells',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'Tregs',
 'ValveOther',
 nan}
```

Example 34 (python):
```python
adata.obs['cell_type3']=adata.obs['leiden_scVI'].astype('str').copy()
adata.obs.replace({'cell_type3':{
    '0':'CD4+T', 
    '1':'NK', 
    '2':'CD4+Treg', 
    '3':'B_MS4A1+', # MS4A1, IgD, CellTypist
    '4':'CD8+T', 
    '5':'ILC',  
    '6':'B', 
    '7':'CD4+T',  
    '8':'CD4+T', 
    '9':'CD4+T', 
    '10':'T_cycling',  
    '11':'NK',
    '12':'Bpro', # CD34, RAG genes, CellTypist
    '13':'B_cycling', 
    '14':'CD8+T', 
    '15':'B_MS4A1+',# MS4A1, IgD, CellTypist
    '16':'B_MS4A1+',# MS4A1, IgD, CellTypist
    '17':'B', 
    '18':'CD4+Treg', 
    '19':'B_MS4A1+',# MS4A1, IgD, CellTypist
    '20':'ILC',
    '21':'B_MS4A1+',# MS4A1, IgD, CellTypist
}}, inplace=True)


adata.obs['cell_type3']=adata.obs['cell_type3'].astype('category')
adata.obs['cell_type3'].cat.reorder_categories([
    'CD4+T',
    'CD4+Treg',
    'CD8+T',
    'NK', 
    'ILC',
    'T_cycling', 
    'Bpro',
    'B', 
    'B_MS4A1+',
    'B_cycling',
    # 'Doublet'
], inplace=True)

adata.obs['cell_type3'].value_counts()
```

Example 35 (unknown):
```unknown
CD4+T        5206
B_MS4A1+     3722
NK           2437
CD8+T        2121
CD4+Treg     1940
B            1666
ILC          1639
T_cycling     912
Bpro          850
B_cycling     843
Name: cell_type3, dtype: int64
```

Example 36 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B','TRAC','TRBC1','TRDC','TRGC1'],
    'naive': ['TCF7', 'LEF1', 'SELL'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2'],
    'cytotoxic': ['PRF1', 'GZMB', 'GZMH', 'NKG7'],
    'NK': ['KLRF1', 'KLRD1', 'NCAM1','FCGR3A','IFNG'],
    'ILC3': ['KIT', 'IL18R1','RORC','IL17A'],
    
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1','IL7R',],
    '':['CCR7','TNFRSF13B',],
    'ProB':['KIT','SPN','CD34'],
    'B1':['CD27','CCR10','MS4A1','SPN'],
    'Plasma': ['CD27','CCR10','CD38','SDC1','JCAIN'],
    'Abs':['IGHM','IGHD', 'IGHG1','IGHG2', 'IGHG3','IGHG4', 'IGHA1','IGHE','IGLC1','IGKC'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    
    
    'Cycling':['MKI67','TOP2A'],

    'TFs': ['TBX21', 'GATA3', 'RORC', 'BCL6',],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 37 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','TRAC','TRBC1','TRBV1','TRBV2'],
     'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1','IL7R',],
   
    
    'Mono':['CCR2','CD14','FCGR3A','CX3CR1','FCGR1A','FCN1','TREM2'],
    'MP':['C1QA','C1QB','CD68','CD163','MERTK','LYVE1','IGF1','TIMD4','CX3CR1','DOCK4','COL1A1','COL1A2','COL3A1'],
    'DC1':['ID2','IRF8','BATF3','CLEC9A'],
    'DC2':['CLEC10A','CD1C','FCER1A',],
    'pDC':['IRF8','IRF4','IL3RA'],
    
   
    'Mast': ['KIT', 'CPA3','HDC','GATA2'],
    'Megakaryocyte':['ITGA2B','MPL','ITGB3',],
    'mesenchymalMP':['COL1A1','COL1A2','COL3A1','C1QA','C1QC','C1QD','VSIG4','COL3A1', 'MDK', 'SPARC', 'ELN'],
    'vCM': ['MYH7', 'MYL2', 'FHL2'],
    'aCM': ['NPPA', 'MYL7', 'MYL4'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 38 (python):
```python
sc.settings.set_figure_params(dpi=120,  color_map = 'RdPu',)
sc.pl.umap(adata, color=['cell_type3'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 39 (python):
```python
sc.tl.rank_genes_groups(adata, 'cell_type3', method='t-test')

DEG_dict = {}
for cluster in adata.obs['cell_type3'].cat.categories:
    df=rank_genes_groups_to_df(adata, cluster)
    # select genes: significant and up-regulated ones
    df=df[(df['pvals_adj']<0.05)&(df['logfoldchanges']>0)]
    # sort based on the logFC
    df.sort_values('scores',ascending=False,inplace=True)
    DEG_dict[cluster]=list(df[:10]['names'])
    del df

sc.pl.dotplot(adata,
              DEG_dict, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 40 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2'],
    'cytotoxic': ['PRF1', 'GZMB','NKG7'],
    'NK': ['KLRF1', 'KLRD1','NCAM1','FCGR3A','IFNG'],
    'ILC': ['KIT', 'IL7R','IL18R1','RORC','IL17A'],   
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1'],
     'ProB':['CD34'],
    'B1':['CD27','CCR10'],
    'Igs':['IGHM','IGHD'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    'Cycling':['MKI67','TOP2A'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata[adata.obs['cell_type3']!='Doublet'],
              markers, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 41 (python):
```python
markers={
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1'],
     'ProB':['CD34'],
    'B1':['CD27','CCR10'],
    'Igs':['IGHM','IGHD'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    'Cycling':['MKI67','TOP2A'],
    'Checking':['JCHAIN','CD38','SDC1'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata[adata.obs['cell_type3']!='Doublet'],
              markers, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 42 (python):
```python
adata.obs['cell_type3'].astype('str') + ' | ' + adata.obs['cell_or_nuclei'].astype('str')
```

Example 43 (unknown):
```unknown
barcode
BHF_F_Hea10402917_ATGTGTGTCGAACGGA-1                                ILC | cell
BHF_F_Hea10402917_CAGGTGCAGGCTATCT-1                                  B | cell
BHF_F_Hea10402917_ATAACGCTCCACGACG-1                              CD4+T | cell
BHF_F_Hea10402917_CACAGTAGTATAGGGC-1                          B_cycling | cell
BHF_F_Hea10402917_GCTGGGTGTGCGGTAA-1                           B_MS4A1+ | cell
                                                                   ...        
HCAHeartST13386010_HCAHeartST13303420_AATTTGCCATAAGCAA-1           NK | nuclei
HCAHeartST13386010_HCAHeartST13303420_GGATTGCGTGGTTCTT-1    B_cycling | nuclei
HCAHeartST13386010_HCAHeartST13303420_TGTGCGGGTGTCACGG-1     CD4+Treg | nuclei
HCAHeartST13386010_HCAHeartST13303420_CTATTCAGTAGGATTT-1          ILC | nuclei
HCAHeartST13386010_HCAHeartST13303420_CTCACACTCGACCTGA-1     CD4+Treg | nuclei
Length: 21336, dtype: object
```

Example 44 (python):
```python
# celltype x cell_nuclei
adata.obs['cell_type3_cllnuclei'] = adata.obs['cell_type3'].astype('str') + ' | ' + adata.obs['cell_or_nuclei'].astype('str')

markers={
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1'],
     'ProB':['CD34'],
    'B1':['CD27','CCR10'],
    'Igs':['IGHM','IGHD'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    'Cycling':['MKI67','TOP2A'],
    'Checking':['JCHAIN','CD38','SDC1'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata[(adata.obs['cell_type3']!='Doublet')&(adata.obs['cell_or_nuclei']!='na')&(adata.obs['cell_type3'].isin(['B','B_MS4A1+','B_cycling']))],
              markers, 
              groupby='cell_type3_cllnuclei',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 45 (unknown):
```unknown
... storing 'cell_type3_cllnuclei' as categorical
```

Example 46 (python):
```python
sc.pl.umap(adata, color=['cell_or_nuclei'], groups='cell', size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 47 (unknown):
```unknown
... storing 'cell_type3_cllnuclei' as categorical
```

Example 48 (python):
```python
sc.pl.umap(adata, color=['cell_or_nuclei'], groups='nuclei', size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 49 (python):
```python
# celltype x cell_nuclei
markers={
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1'],
     'ProB':['CD34'],
    'B1':['CD27','CCR10'],
    'Igs':['IGHM','IGHD'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    'Cycling':['MKI67','TOP2A'],
    'Checking':['JCHAIN','CD38','SDC1'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata[(adata.obs['cell_type3']!='Doublet')&(adata.obs['cell_or_nuclei']=='nuclei')],
              markers, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 50 (python):
```python
adata_raw=sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_immune_16Feb2023.h5ad')
print(adata_raw.shape)

adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp # from annotated or subsetted data
                               )
print(adata_raw.shape)
```

Example 51 (unknown):
```unknown
(41881, 36601)
(21336, 36601)
```

Example 52 (python):
```python
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Lymphoid_16Feb2023.h5ad')
adata_raw
```

Example 53 (unknown):
```unknown
AnnData object with n_obs × n_vars = 21336 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2', 'cell_type3'
    var: 'gene_name_scRNA-0', 'gene_id'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 54 (python):
```python
sc.pl.umap(adata_raw, color=['cell_type3'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 55 (python):
```python
# save metadata
adata_raw.obs.to_csv('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Lymphoid_16Feb2023.obs.csv')
```

Example 56 (python):
```python
# read in saved object
adata_raw = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Lymphoid_16Feb2023.h5ad')
adata_raw
```

Example 57 (python):
```python
# log-normalise
adata = adata_raw.copy()
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
```

Example 58 (python):
```python
adata.X.data[:10]
```

Example 59 (unknown):
```unknown
array([0.20843568, 0.38083044, 0.20843568, 0.20843568, 0.20843568,
       0.38083044, 0.38083044, 0.76952875, 0.38083044, 0.38083044],
      dtype=float32)
```

Example 60 (python):
```python
# cell cycle genes
cell_cycle_genes = [x.strip() for x in open('/nfs/team205/kk18/data/geneset/scanpy_cell_cycle_vignette_files/regev_lab_cell_cycle_genes.txt')]

s_genes = cell_cycle_genes[:43]
g2m_genes = cell_cycle_genes[43:]

# select genes which are in the adata
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]
s_genes = [x for x in s_genes if x in adata.var_names]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
```

Example 61 (python):
```python
%%time
adata_reg = adata.copy()

# scaling and scoring
sc.pp.scale(adata_reg)
sc.tl.score_genes_cell_cycle(adata_reg, s_genes=s_genes, g2m_genes=g2m_genes)

# Running a PCA on cell cycle genes reveals, unsurprisingly, cells separate by phase
adata_cc_genes = adata_reg[:, cell_cycle_genes]
sc.tl.pca(adata_cc_genes)
sc.pl.pca_scatter(adata_cc_genes, color=['phase','cell_type3'])
```

Example 62 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 63 (unknown):
```unknown
CPU times: user 13.8 s, sys: 10.1 s, total: 23.9 s
Wall time: 20.1 s
```

Example 64 (python):
```python
%%time

# regress out
sc.pp.regress_out(adata_reg, ['S_score', 'G2M_score'])
sc.pp.scale(adata_reg)

# When running a PCA on only cell cycle genes, cells no longer separate by cell-cycle phase
adata_cc_genes = adata_reg[:, cell_cycle_genes]
sc.tl.pca(adata_cc_genes)
sc.pl.pca_scatter(adata_cc_genes, color=['phase','cell_type3'])
```

Example 65 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 66 (unknown):
```unknown
CPU times: user 7h 15min 49s, sys: 12h 43min 29s, total: 19h 59min 19s
Wall time: 2h 6min 26s
```

Example 67 (python):
```python
# save regressed out object
adata_reg.write('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Lymphoid_16Feb2023_CCregressed-scaled.h5ad')
adata_reg
```

Example 68 (unknown):
```unknown
AnnData object with n_obs × n_vars = 21336 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2', 'cell_type3', 'S_score', 'G2M_score', 'phase'
    var: 'gene_name_scRNA-0', 'gene_id', 'mean', 'std'
    uns: 'log1p'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 69 (python):
```python
adata_reg = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Lymphoid_16Feb2023_CCregressed-scaled.h5ad')
adata_reg
```

Example 70 (unknown):
```unknown
AnnData object with n_obs × n_vars = 21336 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2', 'cell_type3', 'S_score', 'G2M_score', 'phase'
    var: 'gene_name_scRNA-0', 'gene_id', 'mean', 'std'
    uns: 'log1p'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 71 (python):
```python
adata_nc = adata_reg[adata_reg.obs['cell_type3'].isin(['CD4+T',
                                                        'CD4+Treg',
                                                        'CD8+T',
                                                        'NK', 
                                                        'ILC',
                                                        ])]
adata_nc.obs['cell_type3'].value_counts()
```

Example 72 (unknown):
```unknown
CD4+T       5206
NK          2437
CD8+T       2121
CD4+Treg    1940
ILC         1639
Name: cell_type3, dtype: int64
```

Example 73 (python):
```python
# downsize for training
adata_nc = sctk.subsample(adata_nc, 
                     fraction=1, 
                     groupby='cell_type3', 
                     min_n=0, max_n=1000, method='random', index_only=False, random_state=0)
adata_nc.obs['cell_type3'].value_counts()
```

Example 74 (unknown):
```unknown
CD4+T       1000
CD4+Treg    1000
CD8+T       1000
NK          1000
ILC         1000
Name: cell_type3, dtype: int64
```

Example 75 (python):
```python
%%time
# train
lr = sctk.LR_train(adata_nc, groupby='cell_type3', use_rep='X',)
```

Example 76 (unknown):
```unknown
CPU times: user 2h 23min 55s, sys: 11.5 s, total: 2h 24min 7s
Wall time: 2h 27min 15s
```

Example 77 (unknown):
```unknown
LogisticRegression(C=0.1, n_jobs=-1, solver='saga', warm_start=True)
```

Example 78 (python):
```python
import joblib

outdir = os.path.dirname('/home/jovyan/projects/P37_Foetal-heart_scnRNA/notebooks/v20230207_withShinhalab/LR/foetal_heart_T-NK-ILC_wo-cycling')
if outdir:
    os.makedirs(outdir, exist_ok=True)
joblib.dump(lr, '/home/jovyan/projects/P37_Foetal-heart_scnRNA/notebooks/v20230207_withShinhalab/LR/foetal_heart_T-NK-ILC_wo-cycling')
```

Example 79 (unknown):
```unknown
['/home/jovyan/projects/P37_Foetal-heart_scnRNA/notebooks/v20230207_withShinhalab/LR/foetal_heart_T-NK-ILC_wo-cycling']
```

Example 80 (python):
```python
adata_cyc = adata_reg[adata_reg.obs['cell_type3']=='T_cycling']
adata_cyc
```

Example 81 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 912 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2', 'cell_type3', 'S_score', 'G2M_score', 'phase'
    var: 'gene_name_scRNA-0', 'gene_id', 'mean', 'std'
    uns: 'log1p'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 82 (python):
```python
result = sctk.LR_predict(adata_cyc, lr, use_rep='X',return_predict=True)
```

Example 83 (unknown):
```unknown
36601 features used for prediction
```

Example 84 (python):
```python
print(result['label'][:5])
result['prob'].head()
```

Example 85 (unknown):
```unknown
['ILC' 'ILC' 'ILC' 'NK' 'NK']
```

Example 86 (python):
```python
adata.obs['LR']=np.nan
adata.obs.loc[result['prob'].index,'LR']=result['label']
adata.obs['LR'].value_counts()
```

Example 87 (unknown):
```unknown
CD4+T       454
CD8+T       176
CD4+Treg    156
ILC          80
NK           46
Name: LR, dtype: int64
```

Example 88 (python):
```python
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=['cell_type3','LR'], legend_fontsize=5)
```

Example 89 (unknown):
```unknown
... storing 'LR' as categorical
```

Example 90 (python):
```python
Tcycling_ids = adata.obs_names[adata.obs['LR'].isna()==False]

adata.obs['cell_type4'] = adata.obs['cell_type3'].copy()
adata.obs['cell_type5'] = adata.obs['cell_type3'].copy()
adata.obs['cell_type4'] = adata.obs['cell_type4'].astype('str')
adata.obs['cell_type5'] = adata.obs['cell_type5'].astype('str')
adata.obs.loc[Tcycling_ids,'cell_type4'] = adata.obs.loc[Tcycling_ids,'LR'].astype('str')+'_cycling'
adata.obs.loc[Tcycling_ids,'cell_type5'] = adata.obs.loc[Tcycling_ids,'LR']
adata.obs['cell_type4'].value_counts()
```

Example 91 (unknown):
```unknown
CD4+T               5206
B_MS4A1+            3722
NK                  2437
CD8+T               2121
CD4+Treg            1940
B                   1666
ILC                 1639
Bpro                 850
B_cycling            843
CD4+T_cycling        454
CD8+T_cycling        176
CD4+Treg_cycling     156
ILC_cycling           80
NK_cycling            46
Name: cell_type4, dtype: int64
```

Example 92 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2','PDCD1','TIGIT'],
    'cytotoxic': ['PRF1', 'GZMB','NKG7'],
    'NK': ['KLRF1', 'KLRD1','NCAM1','FCGR3A','IFNG'],
    'ILC': ['KIT', 'IL7R','IL18R1','RORC','IL17A']
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='cell_type4',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 93 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2','PDCD1','TIGIT'],
    'cytotoxic': ['PRF1', 'GZMB','NKG7'],
    'NK': ['KLRF1', 'KLRD1','NCAM1','FCGR3A','IFNG'],
    'ILC': ['KIT', 'IL7R','IL18R1','RORC','IL17A']
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata[adata.obs['cell_type5'].isin(['CD4+T','CD4+Treg','CD8+T','ILC','NK'])],
              markers, 
              groupby='cell_type5',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 94 (python):
```python
adata_Tcycling = adata[Tcycling_ids]
adata_Tcycling.shape
```

Example 95 (unknown):
```unknown
(912, 36601)
```

Example 96 (python):
```python
adata_Tcycling.obs['cell_type5'].value_counts()
```

Example 97 (unknown):
```unknown
CD4+T       454
CD8+T       176
CD4+Treg    156
ILC          80
NK           46
Name: cell_type5, dtype: int64
```

Example 98 (python):
```python
FineGrainKey='cell_type5'
for k in list(set(adata_Tcycling.obs[FineGrainKey])):
    k_mod = k.replace('+','')
    np.savetxt('/nfs/team205/heart/anndata_objects/Foetal/Immune/Tcycling/'+k_mod+'.txt', adata_Tcycling[adata_Tcycling.obs[FineGrainKey]==k,:].obs_names, delimiter="\n", fmt="%s")
    print(k)
```

Example 99 (unknown):
```unknown
NK
CD4+T
CD4+Treg
CD8+T
ILC
```

Example 100 (unknown):
```unknown
rclone copy /nfs/team205/heart/anndata_objects/Foetal/Immune/Tcycling \
gdrive:JamesC_Kazumasa/Foetal_Heart/SanjayShinha/toSinhalab/anndata/Immune_16Feb2023/Tcycling
```

Example 101 (python):
```python
# load model and predict
panfetal_model = models.Model.load('/nfs/team205/kk18/Analysis/celltypist/models/celltypist_model.Pan_Fetal_Human.pkl')
sc.pp.neighbors(adata, use_rep="X_scVI")
prediction=celltypist.annotate(adata, model = panfetal_model, majority_voting = True)
```

Example 102 (unknown):
```unknown
🔬 Input data has 21336 cells and 28811 genes
🔗 Matching reference genes in the model
🧬 6669 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
👀 Detected a neighborhood graph in the input object, will run over-clustering on the basis of it
⛓️ Over-clustering input data with resolution set to 15
🗳️ Majority voting the predictions
✅ Majority voting done!
```

Example 103 (unknown):
```unknown
celltypist.dotplot(prediction, use_as_reference = 'cell_type3', use_as_prediction = 'predicted_labels')
```

Example 104 (python):
```python
import seaborn as sns
plt.rcParams['figure.figsize'] = 12,5
df=pd.crosstab(adata.obs['cell_type3'],adata.obs['2Jan_fine_grain'],normalize='columns')
sns.heatmap(df)
```

Example 105 (unknown):
```unknown
<AxesSubplot:xlabel='2Jan_fine_grain', ylabel='cell_type3'>
```

Example 106 (python):
```python
import seaborn as sns
plt.rcParams['figure.figsize'] = 12,5
ad=adata[adata.obs['2Jan_fine_grain']!='nan']
df=pd.crosstab(ad.obs['cell_type3'],ad.obs['2Jan_fine_grain'],normalize='index')
sns.heatmap(df)
```

Example 107 (unknown):
```unknown
<AxesSubplot:xlabel='2Jan_fine_grain', ylabel='cell_type3'>
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig5_Trisomy21/no05_euploid-trisomy21_post-scVI_incpect-all-conditions.html

**Contents:**
- Read in original adata¶
- Add scVI latent space¶
- Find neighbors, UMAP/Clustering¶

**Examples:**

Example 1 (python):
```python
import scanpy as sc
import pandas as pd
import numpy as np
import anndata
import scipy

import os

import matplotlib.pyplot as plt
import seaborn as sns

import warnings
warnings.simplefilter("ignore", UserWarning)
```

Example 2 (python):
```python
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 3 (python):
```python
import session_info
session_info.show()
```

Example 4 (python):
```python
-----
anndata             0.9.2
matplotlib          3.7.2
numpy               1.22.4
pandas              1.5.3
scanpy              1.9.3
scipy               1.10.1
seaborn             0.12.2
session_info        1.0.0
-----
```

Example 5 (python):
```python
PIL                         10.0.0
anyio                       NA
arrow                       1.2.3
asciitree                   NA
asttokens                   NA
attr                        23.1.0
attrs                       23.1.0
babel                       2.12.1
backcall                    0.2.0
brotli                      1.0.9
certifi                     2023.11.17
cffi                        1.15.1
charset_normalizer          3.2.0
cloudpickle                 3.0.0
colorama                    0.4.6
comm                        0.1.4
cycler                      0.10.0
cython_runtime              NA
dask                        2023.5.0
dateutil                    2.8.2
debugpy                     1.6.8
decorator                   5.1.1
defusedxml                  0.7.1
executing                   1.2.0
fasteners                   0.19
fastjsonschema              NA
fqdn                        NA
h5py                        3.9.0
idna                        3.4
igraph                      0.10.6
importlib_metadata          NA
importlib_resources         NA
ipykernel                   6.25.1
isoduration                 NA
jedi                        0.19.0
jinja2                      3.1.2
joblib                      1.3.2
json5                       NA
jsonpointer                 2.0
jsonschema                  4.19.0
jsonschema_specifications   NA
jupyter_events              0.7.0
jupyter_server              2.7.1
jupyterlab_server           2.24.0
kiwisolver                  1.4.5
leidenalg                   0.10.1
llvmlite                    0.38.1
markupsafe                  2.1.3
mpl_toolkits                NA
natsort                     8.4.0
nbformat                    5.9.2
numba                       0.55.2
numcodecs                   0.12.1
opt_einsum                  v3.3.0
overrides                   NA
packaging                   23.1
parso                       0.8.3
patsy                       0.5.3
pexpect                     4.8.0
pickleshare                 0.7.5
pkg_resources               NA
plotly                      5.16.1
prometheus_client           NA
prompt_toolkit              3.0.39
psutil                      5.9.5
ptyprocess                  0.7.0
pure_eval                   0.2.2
pyarrow                     15.0.2
pydev_ipython               NA
pydevconsole                NA
pydevd                      2.9.5
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pygments                    2.16.1
pyparsing                   3.0.9
pythonjsonlogger            NA
pytz                        2023.3
referencing                 NA
requests                    2.31.0
rfc3339_validator           0.1.4
rfc3986_validator           0.1.1
rpds                        NA
ruamel                      NA
send2trash                  NA
six                         1.16.0
sklearn                     1.3.0
sniffio                     1.3.0
socks                       1.7.1
sphinxcontrib               NA
stack_data                  0.6.2
statsmodels                 0.14.0
texttable                   1.6.7
threadpoolctl               3.2.0
tlz                         0.12.1
toolz                       0.12.1
torch                       1.13.1+cu117
tornado                     6.3.3
tqdm                        4.66.1
traitlets                   5.9.0
typing_extensions           NA
uri_template                NA
urllib3                     2.0.4
wcwidth                     0.2.6
webcolors                   1.13
websocket                   1.6.2
yaml                        6.0.1
zarr                        2.16.1
zipp                        NA
zmq                         25.1.1
zstandard                   0.19.0
```

Example 6 (unknown):
```unknown
-----
IPython             8.12.0
jupyter_client      8.3.0
jupyter_core        4.12.0
jupyterlab          4.0.5
notebook            7.0.2
-----
Python 3.8.17 (default, Jul  5 2023, 21:04:15) [GCC 11.2.0]
Linux-5.15.0-116-generic-x86_64-with-glibc2.17
-----
Session information updated at 2024-08-20 13:52
```

Example 7 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 8 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/nfs/team205/kk18/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 9 (unknown):
```unknown
!ls /nfs/team205/heart/anndata_objects/Foetal/trisomy21
```

Example 10 (unknown):
```unknown
archive_ArchR
ArchR
AtlasT21IntegratedRaw.h5ad
AtlasT21IntegratedRaw.obs.csv
AtlasT21ToFIntegratedRaw.h5ad
CellTypist_labelling
Euploid_T21Hearts_Aug2024_sel.h5ad
Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor.h5ad
Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor.obs.csv
Euploid_T21Hearts_July2024_sel_subsampled-donor-10000.h5ad
Euploid_T21Hearts_July2024_sel_subsampled-donor-10000.obs.csv
Euploid_T21Hearts_July2024_sel_subsampled-donor-10000_pseudobulked.h5ad
Euploid_T21Hearts_July2024_sel_subsampled-donor-10000_pseudobulked-perdonor-sum.h5ad
Euploid_T21Hearts_July2024_sel_subsampled-donor-10000_pseudobulked-sum.h5ad
T21-Healthy_RNA_raw_forArchR.h5ad
T21-Healthy_RNA_raw_forArchR.rds
T21Hearts_cleaned_July2024.h5ad
T21Hearts_cleaned_July2024.obs.csv
T21HeartsExtracardiacRemovedIntegratedProcessed.h5ad
T21HeartsExtracardiacRemovedRaw.h5ad
T21HeartsExtracardiacRemovedRaw.obs.csv
T21Hearts_July2024.h5ad
```

Example 11 (python):
```python
# atlas
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor.h5ad')
adata
```

Example 12 (unknown):
```unknown
AnnData object with n_obs × n_vars = 83477 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'euploid_or_t21', 'donor_type', 'region_finest', 'flushed', 'scrublet_leiden', 'cluster_scrublet_score', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'celltypist_fine', 'conf_score_fine', 'coarse_grain_merged', 'fine_grain_merged'
    var: 'gene_id', 'gene_name_scRNA-0-0', 'feature_type-1', 'ambient_expression-0-1', 'ambient_expression-1-1', 'ambient_expression-10-1', 'ambient_expression-11-1', 'ambient_expression-12-1', 'ambient_expression-13-1', 'ambient_expression-14-1', 'ambient_expression-2-1', 'ambient_expression-3-1', 'ambient_expression-4-1', 'ambient_expression-5-1', 'ambient_expression-6-1', 'ambient_expression-7-1', 'ambient_expression-8-1', 'ambient_expression-9-1', 'mt-1', 'ribo-1', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
```

Example 13 (unknown):
```unknown
latent_file_name_list = os.listdir('/nfs/team205/heart/anndata_objects/Foetal/scVI/latent_variables')
latent_file_name_list = [x.split('.h5ad')[0] for x in latent_file_name_list if (x!='archive')&('subsampled-per-cellstate-donor_' in x)]
latent_file_name_list
```

Example 14 (unknown):
```unknown
['Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-region_n-layers-2',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-3',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-2',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor_n-layers-2',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor_n-layers-1',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-1',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-region_n-layers-1',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-region_n-layers-3',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor_n-layers-3']
```

Example 15 (python):
```python
for latent_file_name in latent_file_name_list:
    latent_space_condition = latent_file_name.split('subsampled-per-cellstate-donor_')[1]
    latent = sc.read_h5ad(f'/nfs/team205/heart/anndata_objects/Foetal/scVI/latent_variables/{latent_file_name}.h5ad')
    # add latent space
    adata.obsm[f'scVI_latent_{latent_space_condition}']=latent.X.copy()
```

Example 16 (unknown):
```unknown
AnnData object with n_obs × n_vars = 83477 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'euploid_or_t21', 'donor_type', 'region_finest', 'flushed', 'scrublet_leiden', 'cluster_scrublet_score', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'celltypist_fine', 'conf_score_fine', 'coarse_grain_merged', 'fine_grain_merged'
    var: 'gene_id', 'gene_name_scRNA-0-0', 'feature_type-1', 'ambient_expression-0-1', 'ambient_expression-1-1', 'ambient_expression-10-1', 'ambient_expression-11-1', 'ambient_expression-12-1', 'ambient_expression-13-1', 'ambient_expression-14-1', 'ambient_expression-2-1', 'ambient_expression-3-1', 'ambient_expression-4-1', 'ambient_expression-5-1', 'ambient_expression-6-1', 'ambient_expression-7-1', 'ambient_expression-8-1', 'ambient_expression-9-1', 'mt-1', 'ribo-1', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding', 'scVI_latent_correcting-region_n-layers-2', 'scVI_latent_correcting-donor-region_n-layers-3', 'scVI_latent_correcting-donor-region_n-layers-2', 'scVI_latent_correcting-donor_n-layers-2', 'scVI_latent_correcting-donor_n-layers-1', 'scVI_latent_correcting-donor-region_n-layers-1', 'scVI_latent_correcting-region_n-layers-1', 'scVI_latent_correcting-region_n-layers-3', 'scVI_latent_correcting-donor_n-layers-3'
```

Example 17 (unknown):
```unknown
latent_file_name_list.sort()
latent_file_name_list
```

Example 18 (unknown):
```unknown
['Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-1',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-2',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-3',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor_n-layers-1',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor_n-layers-2',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor_n-layers-3',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-region_n-layers-1',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-region_n-layers-2',
 'Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-region_n-layers-3']
```

Example 19 (python):
```python
for latent_file_name in latent_file_name_list:
    latent_space_condition = latent_file_name.split('subsampled-per-cellstate-donor_')[1]
    print(f'##### {latent_space_condition} #####')
    sc.pp.neighbors(adata, use_rep=f'scVI_latent_{latent_space_condition}',n_neighbors=15)
    sc.tl.umap(adata, min_dist=0.2, spread=1.0)# 
    # check batches
    sc.pl.umap(adata, color=['total_counts','pct_counts_mt','pct_counts_ribo','donor','euploid_or_t21'], 
               size=5, wspace=0.3, ncols=6, components='all',cmap='RdPu')
    print('')
    print('')
```

Example 20 (unknown):
```unknown
##### correcting-donor-region_n-layers-1 #####
```

Example 21 (unknown):
```unknown
##### correcting-donor-region_n-layers-2 #####
```

Example 22 (unknown):
```unknown
##### correcting-donor-region_n-layers-3 #####
```

Example 23 (unknown):
```unknown
##### correcting-donor_n-layers-1 #####
```

Example 24 (unknown):
```unknown
##### correcting-donor_n-layers-2 #####
```

Example 25 (unknown):
```unknown
##### correcting-donor_n-layers-3 #####
```

Example 26 (unknown):
```unknown
##### correcting-region_n-layers-1 #####
```

Example 27 (unknown):
```unknown
##### correcting-region_n-layers-2 #####
```

Example 28 (unknown):
```unknown
##### correcting-region_n-layers-3 #####
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Neural/NeuralDE.html

**Contents:**
- Subcluster¶

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-09-01 22:04.
```

Example 5 (python):
```python
sc.settings.set_figure_params(dpi=300, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
```

Example 6 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 7 (unknown):
```unknown
(297473, 36601)
```

Example 8 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 9 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 10 (python):
```python
#Expression: "YlGn" (e.g. DE plots)
#Divergent expression: "PRGn" (e.g. log2FC)
#Age: "afmhot_r"
#Others: "viridis" (e.g. UMAP expression)

#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodePacemakerCells':'#854834',
    'AtrioventricularNodePacemakerCells':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParasympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 11 (python):
```python
set(adata.obs.fine_grain)
```

Example 12 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 13 (python):
```python
set(adata.obs.mid_grain)
```

Example 14 (unknown):
```unknown
{'AtrialCardiomyocytes',
 'BloodVesselEndothelialCells',
 'CardiacConductionSystem',
 'EndocardialCells',
 'EpicardialCells',
 'Fibroblasts',
 'Glia',
 'LymphaticEndothelialCells',
 'LymphoidCells',
 'MuralCells',
 'MyeloidCells',
 'Neurons',
 'PericardialCells',
 'VentricularCardiomyocytes'}
```

Example 15 (python):
```python
set(adata.obs.coarse_grain)
```

Example 16 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Leukocytes',
 'Mesenchymal',
 'Neural'}
```

Example 17 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['Myofibroblasts','CoronaryVesselAdventitialFibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts'])].copy()
#adata = adata[adata.obs['mid_grain'].isin(['PericardialCells'])].copy()
adata=adata[adata.obs.coarse_grain=='Neural',:].copy()
```

Example 18 (unknown):
```unknown
AnnData object with n_obs × n_vars = 6149 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 19 (python):
```python
set(adata.obs.fine_grain)
```

Example 20 (unknown):
```unknown
{'CoronaryVesselAdventitialFibroblasts',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'SubEpicardialFibroblasts'}
```

Example 21 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 22 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:08)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1543
```

Example 23 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['PCNA', 'FEN1', 'MCM4', 'RRM1', 'UNG', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    369 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'ANP32E', 'CDC25C', 'RANGAP1', 'NCAPD2', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    811 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 24 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 25 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:27<00:00,  1.82it/s, loss=779, v_num=1]
```

Example 26 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['FOSB', 'JUND', 'SOCS3', 'CEBPB', 'ATF3', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'BTG1', 'DUSP1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    394 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    344 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:04)
```

Example 27 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 28 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 29 (python):
```python
for k in list(set(adata.obs.region)):
    sc.pl.umap(adata, color='region',groups=k,palette=['red','blue'])
```

Example 30 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 31 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 32 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 33 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 34 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 35 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 36 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 37 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 38 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 39 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 40 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 41 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 42 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 43 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 44 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 45 (python):
```python
sc.pl.umap(adata, color='fine_grain')
sc.pl.umap(adata, color='mid_grain')
```

Example 46 (python):
```python
set(adata.obs.fine_grain)
```

Example 47 (unknown):
```unknown
{'ChromaffinCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SympatheticNeurons'}
```

Example 48 (python):
```python
ClusterOfInterest='SchwannCells'
sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
CategoriesOrder=['NeuronPrecursors','SympatheticNeurons','ParaympatheticNeurons','ChromaffinCells','SchwannCellPrecursors','SchwannCells']
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',categories_order=CategoriesOrder,standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 49 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 50 (python):
```python
Genes=['SYT1','PCSK1N','CD24','EML5','PCLO','PHOX2A','ASCL1','NELL2','BNC2','DLL3','FNDC5','STMN2','GATA3','ISL1','RGS5','DBH','VSTM2L','RTN1','ELAVL2','MAPT','PRPH','MTUS1','CADPS','NEFL','PLPP4','CELF4','SST','PRUNE2','SV2C','PGM2L1','TMEM59L','SLC5A7','TENM2','DLK1','EPAS1','KCNJ6','CCSER1','INSM1','VEGFA','NDUFA4L2','ADM','SLC18A2','FZD5','PTPRZ1','CDH19','ERBB3','MEF2C','CDH6','SOX5','LAMA4','COL5A2','MPZ','PLS3','SLITRK6','IL1RAPL2','GFRA1','PTN','PRKG1','COL20A1','IL1RAP','LAMB1','COL4A1','OLFML2A','NR2F2','GASK1B','EGFL8','HSPG2','COL14A1','PLEKHA4','ITGA6','SCN7A','LAMA2','ARHGAP15','NRXN3','SEMA3B','TGFBR3']
CategoriesOrder=['NeuronPrecursors','SympatheticNeurons','ParaympatheticNeurons','ChromaffinCells','SchwannCellPrecursors','SchwannCells']
sc.pl.dotplot(adata, Genes ,groupby='fine_grain',categories_order=CategoriesOrder,standard_scale='var',var_group_positions=[(0,5),(6,10),(11,16),(17,32),(33,42),(43,51),(52,59),(60,75)], var_group_labels=['neurons','neuron precursors','sympathetic neurons','parasympathetic neurons','chromaffin cells','glia','Schwann cell precursors','Schwann cells'], var_group_rotation=45,cmap='YlGn')
```

Example 51 (python):
```python
Genes=['SYT1','PCSK1N','CD24','EML5','PCLO','PHOX2A','ASCL1','NELL2','BNC2','DLL3','FNDC5','STMN2','GATA3','ISL1','RGS5','DBH','VSTM2L','RTN1','ELAVL2','MAPT','PRPH','MTUS1','CADPS','NEFL','PLPP4','CELF4','SST','PRUNE2','SV2C','PGM2L1','TMEM59L','SLC5A7','TENM2','DLK1','EPAS1','KCNJ6','CCSER1','INSM1','VEGFA','NDUFA4L2','ADM','SLC18A2','FZD5']
CategoriesOrder=['NeuronPrecursors','SympatheticNeurons','ParaympatheticNeurons','ChromaffinCells','SchwannCellPrecursors','SchwannCells']
sc.pl.dotplot(adata, Genes ,groupby='fine_grain',categories_order=CategoriesOrder,standard_scale='var',var_group_positions=[(0,5),(6,10),(11,16),(17,32),(33,42)], var_group_labels=['neurons','neuron precursors','sympathetic neurons','parasympathetic neurons','chromaffin cells'], var_group_rotation=45,cmap='YlGn')
```

Example 52 (python):
```python
Genes=['PTPRZ1','CDH19','ERBB3','MEF2C','CDH6','SOX5','LAMA4','COL5A2','MPZ','PLS3','SLITRK6','IL1RAPL2','GFRA1','PTN','PRKG1','COL20A1','IL1RAP','LAMB1','COL4A1','OLFML2A','NR2F2','GASK1B','EGFL8','HSPG2','COL14A1','PLEKHA4','ITGA6','SCN7A','LAMA2','ARHGAP15','NRXN3','SEMA3B','TGFBR3']
CategoriesOrder=['NeuronPrecursors','SympatheticNeurons','ParaympatheticNeurons','ChromaffinCells','SchwannCellPrecursors','SchwannCells']
sc.pl.dotplot(adata, Genes ,groupby='fine_grain',categories_order=CategoriesOrder,standard_scale='var',var_group_positions=[(0,8),(9,16),(17,32)], var_group_labels=['glia','Schwann cell precursors','Schwann cells'], var_group_rotation=45,cmap='YlGn')
```

Example 53 (python):
```python
#adata.write('./ObjectsToUpload/Neural.h5ad')
```

Example 54 (python):
```python
adata=sc.read('./ObjectsToUpload/Neural.h5ad')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no05_clustering-umap_per-mid.html

**Contents:**
- Read in adata¶
- Log-normalisation¶
- Save UMAP and leiden clustering results¶

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os
import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.45.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-05-30 00:17
```

Example 7 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 8 (python):
```python
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
adata
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'dendrogram_pca_harmony_leiden_1.0', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 10 (unknown):
```unknown
os.getcwd()
```

Example 11 (unknown):
```unknown
'/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/Xenium/5K/C194_Hst45/CamU'
```

Example 12 (python):
```python
adata.X.data[:5]
```

Example 13 (unknown):
```unknown
array([5., 1., 1., 2., 2.], dtype=float32)
```

Example 14 (python):
```python
latent_space = 'pca_harmony'
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color='celltypist_mid_fin',
                   )
```

Example 15 (python):
```python
adata.obs['celltypist_mid_fin'].value_counts()
```

Example 16 (unknown):
```unknown
celltypist_mid_fin
VentricularCardiomyocytes      188122
Fibroblasts                     49242
AtrialCardiomyocytes            47076
BloodVesselEndothelialCells     20055
MuralCells                      10986
PericardialCells                 8698
unassigned                       7967
Glia                             6976
EpicardialCells                  5206
EndocardialCells                 5202
MyeloidCells                     3965
LymphaticEndothelialCells        3674
LymphoidCells                    3116
Neurons                          1992
Name: count, dtype: int64
```

Example 17 (python):
```python
# log-normalise the count
sc.pp.normalize_total(adata,target_sum=1e4)
sc.pp.log1p(adata)
adata.X.data[:5]
```

Example 18 (unknown):
```unknown
array([4.2093534, 2.6576407, 2.6576407, 3.3151019, 3.3151019],
      dtype=float32)
```

Example 19 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
```

Example 20 (python):
```python
# adata.uns['log1p']['base'] = None
```

Example 21 (python):
```python
%%time
for celltype in adata.obs['celltypist_mid_fin'].unique():
    if celltype == 'unassigned':
        continue
    
    print(f'##### {celltype} #####')
    # subset
    adata_sub = adata[adata.obs['celltypist_mid_fin']==celltype]
    sc.pp.filter_genes(adata_sub, min_cells=3)
    print(adata_sub.shape)
    # HVGs
    sc.pp.highly_variable_genes(adata_sub, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
    print(f'number of hvgs: {sum(adata_sub.var.highly_variable)}')
    # PCA
    sc.tl.pca(adata_sub, use_highly_variable=True)
    # harmony integration
    sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
    # create neighbour graph
    latent_space = 'pca_harmony'
    sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
    # visualisation with umap
    sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
    adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
    del adata_sub.obsm["X_umap"]
    sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                    color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
    # leiden clustering
    resolutions_list = [0.2,0.4,0.6,1]
    for resolution in resolutions_list:
        sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
    sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.3)
    # tissue id
    sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                    color=['total_counts','tissue_block_id'],
                    wspace=0.3)
    # save
    adata_sub.write(f'{adata_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_{celltype}_lognorm.h5ad')
    print('')
```

Example 22 (unknown):
```unknown
##### Fibroblasts #####
```

Example 23 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
```

Example 24 (unknown):
```unknown
(49242, 4999)
number of hvgs: 819
```

Example 25 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:19:58,064 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:20:03,894 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:20:04,127 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:20:14,361 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:20:24,483 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 26 (unknown):
```unknown
<timed exec>:30: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 27 (unknown):
```unknown
##### PericardialCells #####
(8698, 4737)
number of hvgs: 1209
```

Example 28 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:22:08,885 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:22:10,837 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:22:10,858 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:22:11,811 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:22:12,765 - harmonypy - INFO - Converged after 2 iterations
```

Example 29 (unknown):
```unknown
##### MuralCells #####
(10986, 4771)
number of hvgs: 1020
```

Example 30 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:22:38,155 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:22:40,321 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:22:40,360 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:22:41,646 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:22:42,901 - harmonypy - INFO - Converged after 2 iterations
```

Example 31 (unknown):
```unknown
##### Glia #####
(6976, 4699)
number of hvgs: 981
```

Example 32 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:23:02,139 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:23:04,310 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:23:04,336 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:23:05,373 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:23:06,435 - harmonypy - INFO - Converged after 2 iterations
```

Example 33 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:23:24,923 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
```

Example 34 (unknown):
```unknown
##### Neurons #####
(1992, 4270)
number of hvgs: 1142
```

Example 35 (unknown):
```unknown
2025-05-30 00:23:26,337 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:23:26,343 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:23:26,479 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:23:26,614 - harmonypy - INFO - Converged after 2 iterations
```

Example 36 (unknown):
```unknown
##### VentricularCardiomyocytes #####
```

Example 37 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
```

Example 38 (unknown):
```unknown
(188122, 5001)
number of hvgs: 607
```

Example 39 (unknown):
```unknown
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:23:39,519 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:24:01,431 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:24:02,379 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:24:53,142 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:25:46,356 - harmonypy - INFO - Converged after 2 iterations
```

Example 40 (unknown):
```unknown
##### MyeloidCells #####
(3965, 4505)
number of hvgs: 925
```

Example 41 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:32:35,867 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:32:37,357 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:32:37,369 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:32:37,765 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:32:38,171 - harmonypy - INFO - Converged after 2 iterations
```

Example 42 (unknown):
```unknown
##### LymphoidCells #####
(3116, 4614)
number of hvgs: 919
```

Example 43 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:32:48,991 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:32:50,433 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:32:50,444 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:32:50,735 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:32:51,040 - harmonypy - INFO - Converged after 2 iterations
```

Example 44 (unknown):
```unknown
##### BloodVesselEndothelialCells #####
(20055, 4950)
```

Example 45 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 46 (unknown):
```unknown
number of hvgs: 820
```

Example 47 (unknown):
```unknown
2025-05-30 00:33:00,376 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:33:03,215 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:33:03,256 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:33:05,943 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:33:08,587 - harmonypy - INFO - Converged after 2 iterations
```

Example 48 (unknown):
```unknown
##### AtrialCardiomyocytes #####
```

Example 49 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
```

Example 50 (unknown):
```unknown
(47076, 5000)
number of hvgs: 627
```

Example 51 (unknown):
```unknown
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:33:44,353 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:33:49,775 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:33:49,906 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:33:58,663 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:34:06,411 - harmonypy - INFO - Converged after 2 iterations
```

Example 52 (unknown):
```unknown
##### EndocardialCells #####
(5202, 4492)
number of hvgs: 945
```

Example 53 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:35:28,149 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:35:29,818 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:35:29,833 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:35:30,416 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:35:31,000 - harmonypy - INFO - Converged after 2 iterations
```

Example 54 (unknown):
```unknown
##### LymphaticEndothelialCells #####
(3674, 4576)
number of hvgs: 889
```

Example 55 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:35:44,974 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:35:46,515 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:35:46,527 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:35:46,877 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:35:47,224 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/numpy/lib/_nanfunctions_impl.py:1437: RuntimeWarning: All-NaN slice encountered
  return _nanquantile_unchecked(
```

Example 56 (unknown):
```unknown
##### EpicardialCells #####
(5206, 4657)
number of hvgs: 1052
```

Example 57 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_simple.py:287: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var["n_cells"] = number
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-05-30 00:35:57,504 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-30 00:35:59,232 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-30 00:35:59,244 - harmonypy - INFO - Iteration 1 of 10
2025-05-30 00:35:59,798 - harmonypy - INFO - Iteration 2 of 10
2025-05-30 00:36:00,348 - harmonypy - INFO - Converged after 2 iterations
```

Example 58 (unknown):
```unknown
CPU times: user 19min 17s, sys: 21.2 s, total: 19min 39s
Wall time: 16min 21s
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Mesenchymal/Valve.html

**Contents:**
- Subcluster¶

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-06-21 17:45.
```

Example 4 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 5 (unknown):
```unknown
(297473, 36601)
```

Example 6 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 7 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 8 (python):
```python
#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodeCardiomyocytes':'#854834',
    'AtrioventricularNodeCardiomyocytes':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts1':'#8a6800',
    'MyocardialInterstitialFibroblasts2':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 9 (python):
```python
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_16996/2162444827.py in <module>
     65     'InnateLymphoidCells':'#72497f',
     66 }
---> 67 sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)
     68 
     69 MidGrainPalette={

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in umap(adata, **kwargs)
    657     tl.umap
    658     """
--> 659     return embedding(adata, 'umap', **kwargs)
    660 
    661 

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in embedding(adata, basis, color, gene_symbols, use_raw, sort_order, edges, edges_width, edges_color, neighbors_key, arrows, arrows_kwds, groups, components, layer, projection, scale_factor, color_map, cmap, palette, na_color, na_in_legend, size, frameon, legend_fontsize, legend_fontweight, legend_loc, legend_fontoutline, vmax, vmin, vcenter, norm, add_outline, outline_width, outline_color, ncols, hspace, wspace, title, show, save, ax, return_fig, **kwargs)
    250             groups=groups,
    251         )
--> 252         color_vector, categorical = _color_vector(
    253             adata,
    254             value_to_plot,

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in _color_vector(adata, values_key, values, palette, na_color)
   1267         color_map = {
   1268             k: to_hex(v)
-> 1269             for k, v in _get_palette(adata, values_key, palette=palette).items()
   1270         }
   1271         # If color_map does not have unique values, this can be slow as the

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in _get_palette(adata, values_key, palette)
   1233     values = pd.Categorical(adata.obs[values_key])
   1234     if palette:
-> 1235         _utils._set_colors_for_categorical_obs(adata, values_key, palette)
   1236     elif color_key not in adata.uns or len(adata.uns[color_key]) < len(
   1237         values.categories

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_utils.py in _set_colors_for_categorical_obs(adata, value_to_plot, palette)
    388         colors_list = [to_hex(x) for x in cmap(np.linspace(0, 1, len(categories)))]
    389     elif isinstance(palette, cabc.Mapping):
--> 390         colors_list = [to_hex(palette[k], keep_alpha=True) for k in categories]
    391     else:
    392         # check if palette is a list and convert it to a cycler, thus

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_utils.py in <listcomp>(.0)
    388         colors_list = [to_hex(x) for x in cmap(np.linspace(0, 1, len(categories)))]
    389     elif isinstance(palette, cabc.Mapping):
--> 390         colors_list = [to_hex(palette[k], keep_alpha=True) for k in categories]
    391     else:
    392         # check if palette is a list and convert it to a cycler, thus

KeyError: 'AtrioventricularNodePacemakerCells'
```

Example 10 (python):
```python
set(adata.obs.fine_grain)
```

Example 11 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodeCardiomyocytes',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts1',
 'MyocardialInterstitialFibroblasts2',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodeCardiomyocytes',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 12 (python):
```python
set(adata.obs.mid_grain)
```

Example 13 (unknown):
```unknown
{'AtrialCardiomyocytes',
 'BloodVesselEndothelialCells',
 'CardiacConductionSystem',
 'EndocardialCells',
 'EpicardialCells',
 'Fibroblasts',
 'Glia',
 'LymphaticEndothelialCells',
 'LymphoidCells',
 'MuralCells',
 'MyeloidCells',
 'Neurons',
 'PericardialCells',
 'VentricularCardiomyocytes'}
```

Example 14 (python):
```python
set(adata.obs.coarse_grain)
```

Example 15 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Leukocytes',
 'Mesenchymal',
 'Neural'}
```

Example 16 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
adata = adata[adata.obs['fine_grain'].isin(['EndocardialCells','EndocardialCushionCells','ValveEndothelialCells','ValveInterstitialCells'])].copy()
#adata = adata[adata.obs['mid_grain'].isin(['PericardialCells'])].copy()
#adata=adata[adata.obs.mid_grain=='MuralCells',:].copy()
```

Example 17 (unknown):
```unknown
AnnData object with n_obs × n_vars = 16744 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 18 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 19 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:10)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
2188
```

Example 20 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    330 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['CKS1B', 'TMPO', 'ANP32E', 'HJURP', 'CDC25C', 'RANGAP1', 'NCAPD2', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    695 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 21 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 22 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [01:21<00:00,  1.63s/it, loss=945, v_num=1]
```

Example 23 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1', 'BTG2']
    finished: added
    'stress_score', score of gene set (adata.obs).
    442 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBB', 'HBD', 'HBE1', 'HBZ', 'HBM', 'HBA1', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    98 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:03)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:04)
```

Example 24 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 25 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 26 (python):
```python
sc.tl.diffmap(adata)
sc.pl.diffmap(adata, color='fine_grain')
sc.pl.diffmap(adata, color='PECAM1')
```

Example 27 (python):
```python
computing Diffusion Maps using n_comps=15(=n_dcs)
computing transitions
    finished (0:00:00)
    eigenvalues of transition matrix
    [1.         0.99786    0.99074847 0.9877497  0.98542356 0.9823111
     0.98121595 0.9771292  0.9763206  0.97314173 0.97228724 0.96928436
     0.9683964  0.9643321  0.96360725]
    finished: added
    'X_diffmap', diffmap coordinates (adata.obsm)
    'diffmap_evals', eigenvalues of transition matrix (adata.uns) (0:00:00)
```

Example 28 (python):
```python
sc.pl.umap(adata, color='fine_grain')
```

Example 29 (python):
```python
set(adata.obs.fine_grain)
```

Example 30 (unknown):
```unknown
{'EndocardialCells',
 'EndocardialCushionCells',
 'ValveEndothelialCells',
 'ValveInterstitialCells'}
```

Example 31 (python):
```python
ClusterOfInterest='EndocardialCells'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster , groupby='fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 32 (python):
```python
sc.pl.dotplot(adata, ['EMCN','PCDH7','ADGRG6','NPR3','SMOC1','HAS2','PROX1','COL26A1','BMP4','GJA4','TMEM132D','TSPAN8','CNR1','MSX1','APCDD1','HAPLN1','KLF2','FXYD5','LTC4S','CCL21','NFATC1','NRGN','DKK2','KCNJ2','SULF1','GJA1','KISS1','PTN','MFAP4','ID4','PRRX1','BAMBI','INHBA','CLU','TWIST1','COL9A3','COL9A2','IGF1','RSPO3','MMP23B','SCX','COL9A1'] ,var_group_positions=[(0,4),(5,13),(14,26),(27,41)], var_group_labels=['endocardial','endocardial cushion','valve endothelial','valve interstitial'], var_group_rotation=90,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 33 (python):
```python
sc.pl.dotplot(adata, ['EMCN','PCDH7','ADGRG6','NPR3','SMOC1','HAS2','PROX1','COL26A1','BMP4','GJA4','TMEM132D','TSPAN8','CNR1','MSX1','APCDD1','HAPLN1','KLF2','FXYD5','LTC4S','CCL21','NFATC1','NRGN','DKK2','KCNJ2','SULF1','GJA1','KISS1','PTN','MFAP4','ID4','PRRX1','BAMBI','INHBA','CLU','TWIST1','COL9A3','COL9A2','IGF1','RSPO3','MMP23B','SCX','COL9A1','POSTN'] ,var_group_positions=[(0,4),(5,13),(14,26),(27,41)], var_group_labels=['endocardial','endocardial cushion','valve endothelial','valve interstitial'], var_group_rotation=90,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 34 (python):
```python
bdata=adata.copy()
```

Example 35 (python):
```python
bdata=sc.read('./Objects/Feb28ObjectProcessed.h5ad')
print(bdata.shape)
bdata = bdata[bdata.obs['mid_grain'].isin(['Fibroblasts'])].copy()
```

Example 36 (unknown):
```unknown
(297473, 3392)
```

Example 37 (python):
```python
sc.pl.dotplot(bdata, ['CLU','HAPLN1','INHBA','COL9A2','SCX'] ,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 38 (unknown):
```unknown
FineGrainCategoriesOrder=['AtrialCardiomyocytesLeft','AtrialCardiomyocytesRight','AtrialCardiomyocytesCycling','VentricularCardiomyocytesLeftCompact','VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesCycling','SinoatrialNodeCardiomyocytes','AtrioventricularNodeCardiomyocytes','VentricularConductionSystemProximal','VentricularConductionSystemDistal','GreatVesselAdventitialFibroblasts','CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','LymphNodeFibroblasticReticularCells','ValveInterstitialCells','GreatVesselSmoothMuscleCells','CoronarySmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','CoronaryPericytes','PericardialCellsIntermediate','PericardialCellsFibrous','PericardialCellsParietal','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','CoronaryArterialEndothelialCells','CoronaryVenousEndothelialCells','CoronaryCapillaryEndothelialCells','EndocardialCells','EndocardialCushionCells','ValveEndothelialCells','LymphaticEndothelialCells','MesothelialEpicardialCells','EpicardiumDerivedCells','NeuronPrecursors','ChromaffinCells','SympatheticNeurons','ParaympatheticNeurons','SchwannCellPrecursors','SchwannCells','MonocytesMPOpos','Monocytes','MonocyteDerivedCells','MacrophagesCX3CR1pos','MacrophagesTIMD4pos','MacrophagesLYVE1pos','MacrophagesATF3pos','DendriticCellsType1','DendriticCellsMature','PlasmacytoidDendriticCells','MastCells','Megakaryocytes','TCellsCD4pos','TCellsCD8pos','TregsCD4pos','ProBCells','BCells','BCellsMS4A1pos','NaturalKillerCells','InnateLymphoidCells']
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Visium/Visium_Intagration-Annotation/Visium_integration_no2_plots-UMAP-celltypes.html

**Contents:**
- Functions¶
- Read in anndata¶
- Basic plots¶
- Plot cell abundances¶
- Plot clusters on visium sections¶
  - FFPE¶
  - OCT¶
- DotPlot¶
- DA test¶

**Examples:**

Example 1 (python):
```python
import sys
import scanpy as sc
import anndata
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt 
import matplotlib as mpl

from matplotlib import rcParams
rcParams['pdf.fonttype'] = 42 # enables correct plotting of text
import seaborn as sns

import os
```

Example 2 (python):
```python
sc.settings.set_figure_params(dpi=120)
```

Example 3 (python):
```python
# This function selects the data for multiple slides from the spatial anndata object.
# Modified `select_slide` in cell2loc for multiple slides

# @param adata: anndata object with multiple spatial experiments
# @param s: list of selected slides
# @param s_col: column in adata.obs listing experiment name for each location

def select_multislide(adata, s, s_col='sample'):

    slides = adata[adata.obs[s_col].isin(s), :]
    s_keys = list(slides.uns['spatial'].keys())
    
    uns_dict = {}
    for ss in s:
        s_spatial=np.array(s_keys)[[ss in k for k in s_keys]][0]
        uns_dict[s_spatial]=slides.uns['spatial'][s_spatial]
    
    slides.uns['spatial'] = uns_dict

    return slides
```

Example 4 (python):
```python
# the anndata has "gene expression" in .X
# cell2location output is in .obsm['q05_cell_abundance_w_sf']
# kNN graph for UMAP/clustering was generated using cell2location output
adata_vis = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_raw.h5ad')
adata_vis
```

Example 5 (unknown):
```unknown
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 6 (unknown):
```unknown
AnnData object with n_obs × n_vars = 39223 × 33562
    obs: 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'cell2loc-map_group', 'JC_edit', 'sample_for_cell2loc', 'week', 'leiden', 'region_cluster'
    var: 'gene_ids'
    uns: 'JC_edit_colors', 'cell2loc-map_group_colors', 'leiden', 'neighbors', 'region_cluster_colors', 'sample_for_cell2loc_colors', 'umap'
    obsm: 'MT', 'X_umap', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q05_cell_abundance_w_sf_ndarray', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
    obsp: 'connectivities', 'distances'
```

Example 7 (python):
```python
# log-normalise gene expression data
sc.pp.filter_genes(adata_vis, min_cells=3)
sc.pp.normalize_total(adata_vis, target_sum=1e4)
sc.pp.log1p(adata_vis)
```

Example 8 (python):
```python
# just checking
pd.crosstab(adata_vis.obs['sample_for_cell2loc'],adata_vis.obs['cell2loc-map_group'])
```

Example 9 (python):
```python
# just checking
pd.crosstab(adata_vis.obs['JC_edit'],adata_vis.obs['cell2loc-map_group'])
```

Example 10 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['region_cluster','week','sample'], size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False)
```

Example 11 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['region_cluster'], groups=['14','6','4'],size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False)
```

Example 12 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['total_counts','n_genes_by_counts'], size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False)
```

Example 13 (python):
```python
# manually annotated structures, plotting separately
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    
    fig, axs = plt.subplots(nrows=2, ncols=3, figsize=(20,10))
    dotsize = 10
    
    sc.pl.umap(adata_vis, color=['JC_edit'], groups=['Myocardium - Atrial',
                                                 'Myocardium - Papillary Muscle',
                                                 'Myocardium - Ventricular - Compact',
                                                 'Myocardium - Ventricular - Trabeculated'],
               size=dotsize, title='Myocardium', legend_fontsize=10, frameon=False,
              show=False, ax=axs[0,0])

    sc.pl.umap(adata_vis, color=['JC_edit'], groups=['Coronary artery','Great vessels',],
               size=dotsize, title='Vessels',legend_fontsize=10, frameon=False,
              show=False, ax=axs[0,1])
    
    sc.pl.umap(adata_vis, color=['JC_edit'], groups=['AV ring','AV valves','Aortic valve','Valve apparatus'],
               size=dotsize, title='Valves + alpha', legend_fontsize=10, frameon=False,
              show=False, ax=axs[0,2])

    sc.pl.umap(adata_vis, color=['JC_edit'], groups=['AVN','Bundle branch - left','Bundle branch - right'],
               size=dotsize, title='CCSs', legend_fontsize=10, frameon=False,
              show=False, ax=axs[1,0])

    sc.pl.umap(adata_vis, color=['JC_edit'], groups=['Epicardium'],
               size=dotsize, title='Epicardium', legend_fontsize=10, frameon=False,
              show=False, ax=axs[1,1])
    
    sc.pl.umap(adata_vis, color=['JC_edit'], groups=['LN'],
               size=dotsize, title='LN', legend_fontsize=10, frameon=False,
              show=False, ax=axs[1,2])
    plt.tight_layout()
```

Example 14 (python):
```python
# prepare cell2location anndata
cellnames = adata_vis.obsm['q05_cell_abundance_w_sf'].columns
cellnames = [x.split('q05cell_abundance_w_sf_')[1] for x in cellnames]
adata_c2l = anndata.AnnData(
    X=adata_vis.obsm['q05_cell_abundance_w_sf_ndarray'].copy(),
    obs=adata_vis.obs.copy(),
    var=pd.DataFrame(cellnames).set_index(0),
    obsm=adata_vis.obsm.copy(),
    obsp=adata_vis.obsp.copy(),
    uns=adata_vis.uns.copy()
)
adata_c2l
```

Example 15 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/ipykernel_launcher.py:10: FutureWarning: X.dtype being converted to np.float32 from float64. In the next version of anndata (0.9) conversion will not be automatic. Pass dtype explicitly to avoid this warning. Pass `AnnData(X, dtype=X.dtype, ...)` to get the future behavour.
  # Remove the CWD from sys.path while we load stuff.
```

Example 16 (unknown):
```unknown
AnnData object with n_obs × n_vars = 39223 × 58
    obs: 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'cell2loc-map_group', 'JC_edit', 'sample_for_cell2loc', 'week', 'leiden', 'region_cluster'
    uns: 'JC_edit_colors', 'cell2loc-map_group_colors', 'leiden', 'neighbors', 'region_cluster_colors', 'sample_for_cell2loc_colors', 'umap', 'log1p', 'week_colors'
    obsm: 'MT', 'X_umap', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q05_cell_abundance_w_sf_ndarray', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
    obsp: 'connectivities', 'distances'
```

Example 17 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_c2l, color=cellnames, size=20,
               color_map = 'RdPu', ncols = 4, wspace=0.1, vmax='p99.98',
               legend_fontsize=14, frameon=False)
```

Example 18 (python):
```python
# need to read in each object to plot visium section...(as far as i know)

adata_oct = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-OCT_foetal_raw.h5ad')

adata_da = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-OCT_foetal_DuctusA_raw.h5ad')
adata_da.obs['sample_for_cell2loc'] = adata_da.obs['sample'].copy()

adata_ffpe = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-FFPE_foetal_raw.h5ad')
adata_ffpe.obs['sample_for_cell2loc'] = adata_ffpe.obs['sample'].copy()
adata_ffpe.obs['cell2loc-map_group'] = 'FFPE_16PCW'
adata_ffpe = adata_ffpe[adata_ffpe.obs['JC_edit'].isin(['Cavity'])==False]
```

Example 19 (python):
```python
# set color
## for clusters
palette1={}
for i,annot in enumerate(adata_vis.obs['region_cluster'].cat.categories):
    palette1[annot]=adata_vis.uns['region_cluster_colors'][i]

## for JC_edit
colormap='tab20'
palette2={}
for i,annot in enumerate(adata_vis.obs['JC_edit'].cat.categories):
    palette2[annot]=plt.get_cmap(colormap).colors[i]
```

Example 20 (python):
```python
adata_ffpe.obs['region_cluster'] = adata_vis.obs['region_cluster'].reindex(adata_ffpe.obs_names)
slides_to_plot = list(set(adata_ffpe.obs['sample']))

for s in slides_to_plot:
    slide = select_multislide(adata_ffpe, [s])
    with mpl.rc_context({'figure.figsize': [4.5, 4],
                        'axes.titlesize':20,}):
        fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(15,5))

        sc.pl.spatial(slide,
                      color=['region_cluster'], 
                      size=1.2,img_key='hires',alpha_img=0.3, palette=palette1,
                      show=False, ax=axs[0],title = f'region_cluster, {s}'
                     )
        sc.pl.spatial(slide,
                      color=['JC_edit'], 
                      size=1.2,img_key='hires',alpha_img=0.3, palette=palette2,
                      show=False, ax=axs[1], title = f'JC_edit, {s}'
                     )
        plt.tight_layout()
```

Example 21 (python):
```python
slide = select_multislide(adata_ffpe, ['BHF_F_Hea13295831'])

with mpl.rc_context({'figure.figsize': [4.5, 4],
                    'axes.titlesize':20,}):

    fig, axs = plt.subplots(nrows=4, ncols=6, figsize=(20,15))
    for i,g in enumerate(adata_vis.obs['region_cluster'].cat.categories):
        sc.pl.spatial(slide,
                      color=['region_cluster'], groups=g,
                      size=1.2,img_key='hires',alpha_img=0.1, palette=palette1,
                      show=False, ax=axs[i//6,i%6]
                     )
    plt.tight_layout()
```

Example 22 (python):
```python
adata_oct.obs['region_cluster'] = adata_vis.obs['region_cluster'].reindex(adata_oct.obs_names)
slides_to_plot = list(set(adata_oct.obs['sample']))
slides_to_plot.sort()

for s in slides_to_plot:
    slide = select_multislide(adata_oct, [s])
    with mpl.rc_context({'figure.figsize': [4.5, 4],
                        'axes.titlesize':20,}):

        fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(15,5))

        sc.pl.spatial(slide,
                      color=['region_cluster'], 
                      size=1.2,img_key='hires',alpha_img=0.3, palette=palette1,
                      show=False, ax=axs[0], title = f'region_cluster, {s}'
                     )
        sc.pl.spatial(slide,
                      color=['JC_edit'], 
                      size=1.2,img_key='hires',alpha_img=0.3, palette=palette2,
                      show=False, ax=axs[1], title = f'JC_edit, {s}'
                     )
        plt.tight_layout()
```

Example 23 (python):
```python
slide = select_multislide(adata_oct, ['HCAHeartST11605165'])

with mpl.rc_context({'figure.figsize': [4.5, 4],
                    'axes.titlesize':20,}):

    fig, axs = plt.subplots(nrows=4, ncols=6, figsize=(20,15))
    for i,g in enumerate(adata_vis.obs['region_cluster'].cat.categories):
        sc.pl.spatial(slide,
                      color=['region_cluster'], groups=g,
                      size=1.2,img_key='hires',alpha_img=0.1, palette=palette1,
                      show=False, ax=axs[i//6,i%6]
                     )
    plt.tight_layout()
```

Example 24 (python):
```python
sc.pl.dotplot(adata_c2l,
              adata_c2l.var_names, 
              groupby='JC_edit',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 25 (python):
```python
WARNING: dendrogram data not found (using key=dendrogram_JC_edit). Running `sc.tl.dendrogram` with default parameters. For fine tuning it is recommended to run `sc.tl.dendrogram` independently.
WARNING: You’re trying to run this on 58 dimensions of `.X`, if you really want this, set `use_rep='X'`.
         Falling back to preprocessing with `sc.pp.pca` and default params.
```

Example 26 (python):
```python
sc.pl.dotplot(adata_c2l,
              adata_c2l.var_names, 
              groupby='region_cluster',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 27 (python):
```python
WARNING: dendrogram data not found (using key=dendrogram_region_cluster). Running `sc.tl.dendrogram` with default parameters. For fine tuning it is recommended to run `sc.tl.dendrogram` independently.
```

Example 28 (python):
```python
sc.tl.rank_genes_groups(adata_c2l,
                       groupby='region_cluster')
sc.pl.rank_genes_groups_dotplot(adata_c2l,
                               standard_scale='var',
                               dendrogram=False)
```

Example 29 (python):
```python
WARNING: Default of the method has been changed to 't-test' from 't-test_overestim_var'
```

Example 30 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/scanpy/tools/_rank_genes_groups.py:394: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead.  To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, 'names'] = self.var_names[global_indices]
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/scanpy/tools/_rank_genes_groups.py:396: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead.  To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, 'scores'] = scores[global_indices]
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/scanpy/tools/_rank_genes_groups.py:399: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead.  To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, 'pvals'] = pvals[global_indices]
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/scanpy/tools/_rank_genes_groups.py:409: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead.  To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, 'pvals_adj'] = pvals_adj[global_indices]
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/scanpy/tools/_rank_genes_groups.py:421: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead.  To get a de-fragmented frame, use `newframe = frame.copy()`
  foldchanges[global_indices]
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no8_plotting-Copy1.html

**Contents:**
- Read in adata¶
- Log-normalisation¶
- Plot cell types¶
- Plot genes¶
- Plot LR¶
- Plot axonal genes¶

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os
import scanpy.external as sce
```

Example 2 (python):
```python
# import session_info
# session_info.show()
```

Example 3 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 4 (python):
```python
path_adata = '/lustre/scratch126/cellgen/team205/kk18/xenium/objects/foetal/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
adata
```

Example 5 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'fine_grain_8Dec2024', 'multi_celltypes_coarse', 'cluster_cellcharter', 'fine_grain_4Jan2025', 'sliding_window_assignment', 'globalX', 'globalY', 'predicted_labels_sliding_window_assignment', 'conf_score_sliding_window_assignment'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_mid_fin_colors', 'fine_grain_4Jan2025_colors', 'fine_grain_8Dec2024_colors', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'spatial_neighbors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_cellcharter', 'X_pca', 'X_pca_harmony', 'X_umap_pca', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances', 'spatial_connectivities', 'spatial_distances'
```

Example 6 (unknown):
```unknown
os.getcwd()
```

Example 7 (unknown):
```unknown
'/nfs/team205/kk18/notebooks/Foetal/Xenium/5K/C194_Hst45'
```

Example 8 (python):
```python
adata.X.data[:5]
```

Example 9 (unknown):
```unknown
array([5., 1., 1., 2., 2.], dtype=float32)
```

Example 10 (python):
```python
# log-normalise the count
sc.pp.normalize_total(adata,target_sum=1e4)
sc.pp.log1p(adata)
adata.X.data[:5]
```

Example 11 (unknown):
```unknown
array([4.2093534, 2.6576407, 2.6576407, 3.3151019, 3.3151019],
      dtype=float32)
```

Example 12 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]
sc.pl.spatial(slide,color=['fine_grain_8Dec2024'],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','SympatheticNeurons'],
              spot_size=60,vmax='p100',
             )
```

Example 13 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]
sc.pl.spatial(slide,color=['fine_grain_8Dec2024'],
              groups=['SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells','ParasympatheticNeurons','MacrophagesCX3CR1pos','MacrophagesLYVE1pos'],
              spot_size=20,vmax='p100',
              crop_coord=(4500,7000,4000,6000)
             )
```

Example 14 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('MacrophagesCX3CR1pos')]='blue'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('MacrophagesLYVE1pos')]='orange'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','MacrophagesCX3CR1pos','MacrophagesLYVE1pos'],
              spot_size=15,vmax='p100',
              crop_coord=(4600,5600,4250,5250)
             )
```

Example 15 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SchwannCellPrecursors')]='blue'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SchwannCells')]='orange'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','SchwannCells','SchwannCellPrecursors'],
              spot_size=15,vmax='p100',
              crop_coord=(4600,5600,4250,5250)
             )
```

Example 16 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SchwannCellPrecursors')]='blue'
# slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SchwannCells')]='orange'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','SchwannCellPrecursors'],
              spot_size=15,vmax='p100',
              crop_coord=(4600,5600,4250,5250)
             )
```

Example 17 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SchwannCellPrecursors')]='blue'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('Fibroblasts')]='burlywood'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','SchwannCellPrecursors','Fibroblasts'],
              spot_size=15,vmax='p100',
              crop_coord=(4600,5600,4250,5250)
             )
```

Example 18 (python):
```python
tissue_id = 'Hst45-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SchwannCellPrecursors')]='blue'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SchwannCells')]='orange'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','SchwannCells','SchwannCellPrecursors'],
              spot_size=30,vmax='p100',
              crop_coord=(6000,7000,500,3000)
             )
```

Example 19 (python):
```python
tissue_id = 'Hst45-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('MacrophagesCX3CR1pos')]='blue'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('MacrophagesLYVE1pos')]='orange'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('TCellsCD8pos')]='purple'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','MacrophagesCX3CR1pos','MacrophagesLYVE1pos','TCellsCD8pos'],
              spot_size=30,vmax='p100',
              crop_coord=(6000,7000,500,3000)
             )
```

Example 20 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('MacrophagesCX3CR1pos')]='blue'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('MacrophagesLYVE1pos')]='orange'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('TCellsCD8pos')]='purple'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','MacrophagesCX3CR1pos','MacrophagesLYVE1pos','TCellsCD8pos'],
              spot_size=15,vmax='p100',
              crop_coord=(4600,5600,4250,5250)
             )
```

Example 21 (python):
```python
tissue_id = 'Hst45-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('LymphaticEndothelialCells')]='blue'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('MacrophagesLYVE1pos')]='orange'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','LymphaticEndothelialCells'],
              spot_size=50,vmax='p100',
              crop_coord=(6000,7000,500,3000)
             )
```

Example 22 (python):
```python
tissue_id = 'Hst45-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('LymphaticEndothelialCells')]='blue'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('MacrophagesLYVE1pos')]='orange'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','LymphaticEndothelialCells'],
              spot_size=50,vmax='p100',
             )
```

Example 23 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('Fibroblasts')]='blue'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','Fibroblasts'],
              spot_size=15,vmax='p100',
              crop_coord=(4600,5600,4250,5250)
             )
```

Example 24 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('Fibroblasts')]='blue'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','Fibroblasts'],
              spot_size=15,vmax='p100',
              crop_coord=(4500,7000,4000,6000)
             )
```

Example 25 (python):
```python
tissue_id = 'Hst45-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('Fibroblasts')]='blue'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','Fibroblasts'],
              spot_size=15,vmax='p100',
              crop_coord=(6000,7000,500,3000)
             )
```

Example 26 (python):
```python
tissue_id = 'Hst45-HEA-0-FFPE-1'
celltype_key = 'fine_grain_8Dec2024'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('ParasympatheticNeurons')]='springgreen'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('SinoatrialNodePacemakerCells')]='hotpink'
slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index('Fibroblasts')]='blue'

sc.pl.spatial(slide,color=[celltype_key],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','Fibroblasts'],
              spot_size=15,vmax='p100',
             )
```

Example 27 (python):
```python
genes = ['SEMA3A', 'SLIT2', 'SLIT3', 'EFNB2', 'CXCL12', 'FGF10', 'VEGFC', 'NELL1']
genes = [x for x in genes if x in adata.var_names]
genes
```

Example 28 (unknown):
```unknown
['SEMA3A', 'SLIT2', 'SLIT3', 'EFNB2', 'CXCL12', 'FGF10', 'VEGFC', 'NELL1']
```

Example 29 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]
sc.pl.spatial(slide,color=genes,
              spot_size=20,vmax='p100',
              crop_coord=(4700,6000,4600,5300)
             )
```

Example 30 (python):
```python
genes = ['SEMA3A', 'SLIT2', 'SLIT3', 'EFNB2', 'CXCL12', 'FGF10', 'VEGFC', 'NELL1']
genes = [x for x in genes if x in adata.var_names]
genes
```

Example 31 (unknown):
```unknown
['SEMA3A', 'SLIT2', 'SLIT3', 'EFNB2', 'CXCL12', 'FGF10', 'VEGFC', 'NELL1']
```

Example 32 (python):
```python
cpdb_metadata = pd.read_csv('/nfs/team205/heart/cellphonedb/customDB/interaction_meta/interaction_metadata_v5.0.0_2024-1-26.csv')
lr_genes = cpdb_metadata[['gene_name_1', 'gene_name_2']].copy()
print(lr_genes.shape)
lr_genes.head()
```

Example 33 (python):
```python
for i,gene in enumerate(genes):
    mask1 = np.array([gene in x.split(',') for x in lr_genes['gene_name_1']])
    mask2 = np.array([gene in x.split(',') for x in lr_genes['gene_name_2']])
    df = lr_genes.loc[mask1|mask2]
    if i==0:
        lr_genes_sel = df.copy()
    else:
        lr_genes_sel = pd.concat([lr_genes_sel,df])
lr_genes_sel.drop_duplicates(inplace=True)
lr_genes_sel.index = range(len(lr_genes_sel))
lr_genes_sel
```

Example 34 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

for ind in lr_genes_sel.index:
    g = lr_genes_sel.loc[ind,'gene_name_1'].split(',')+lr_genes_sel.loc[ind,'gene_name_2'].split(',')
    g = [x for x in g if x in adata.var_names]
    sc.pl.spatial(slide,color=g,
              spot_size=20,vmax='p100',
              crop_coord=(4700,6000,4600,5300)
             )
```

Example 35 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    df = slide.obs[['cell_id','fine_grain_8Dec2024']]
    df.columns = ['cell_id','group']
    df.to_csv(f'./{tissue_id}_cellgroup_XR_8Dec2024.csv',index=False)
```

Example 36 (python):
```python
genes = ['TUBB3', 'MAP2', 'ARC', 'SLC18A3', 'SLC5A7', 'CAMK2A']
genes = [x for x in genes if x in adata.var_names]
genes
```

Example 37 (unknown):
```unknown
['TUBB3', 'MAP2', 'ARC', 'SLC5A7', 'CAMK2A']
```

Example 38 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]
sc.pl.spatial(slide,color=genes,
              spot_size=20,vmax='p100',
              crop_coord=(4700,6000,4600,5300)
             )
```

Example 39 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]
sc.pl.spatial(slide,color=genes,
              spot_size=60,vmax='p100',
              # crop_coord=(4700,6000,4600,5300)
             )
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/No2_foetal-global_scVI.html

**Contents:**
- Import modules¶
- Read in pre-processed anndata¶
- Setup anndata for scVI¶
- Creating and training a model¶
- Save post-scVI anndata¶

**Examples:**

Example 1 (python):
```python
import anndata
import matplotlib.pyplot as plt
import seaborn as sns

import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import scvi
```

Example 2 (unknown):
```unknown
Global seed set to 0
```

Example 3 (python):
```python
import session_info
session_info.show()
```

Example 4 (python):
```python
-----
anndata             0.7.8
matplotlib          3.5.0
numpy               1.20.3
pandas              1.3.4
scanpy              1.8.2
scvi                0.14.5
seaborn             0.11.2
session_info        1.0.0
-----
```

Example 5 (python):
```python
PIL                         8.4.0
absl                        NA
attr                        21.2.0
backcall                    0.2.0
beta_ufunc                  NA
binom_ufunc                 NA
cached_property             1.5.2
cffi                        1.15.0
colorama                    0.4.4
cycler                      0.10.0
cython_runtime              NA
dateutil                    2.8.2
debugpy                     1.5.1
decorator                   5.1.0
defusedxml                  0.7.1
deprecate                   0.3.0
docrep                      0.3.2
entrypoints                 0.3
fsspec                      2021.11.0
google                      NA
h5py                        3.6.0
igraph                      0.9.8
importlib_metadata          1.7.0
ipykernel                   6.5.1
ipython_genutils            0.2.0
ipywidgets                  7.6.5
jedi                        0.18.1
joblib                      1.1.0
kiwisolver                  1.3.2
leidenalg                   0.8.8
llvmlite                    0.37.0
matplotlib_inline           NA
mpl_toolkits                NA
natsort                     8.0.0
nbinom_ufunc                NA
numba                       0.54.1
numexpr                     2.7.3
opt_einsum                  v3.3.0
packaging                   21.3
parso                       0.8.2
pexpect                     4.8.0
pickleshare                 0.7.5
pkg_resources               NA
prompt_toolkit              3.0.22
ptyprocess                  0.7.0
pycparser                   2.21
pydev_ipython               NA
pydevconsole                NA
pydevd                      2.6.0
pydevd_concurrency_analyser NA
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pygments                    2.10.0
pyparsing                   3.0.6
pyro                        1.7.0
pytorch_lightning           1.3.8
pytz                        2021.3
rich                        NA
scipy                       1.7.3
setuptools                  58.0.4
setuptools_scm              NA
sinfo                       0.3.4
six                         1.16.0
sklearn                     1.0.1
statsmodels                 0.13.1
storemagic                  NA
tables                      3.6.1
tensorboard                 2.7.0
texttable                   1.6.4
threadpoolctl               3.0.0
torch                       1.10.0+cu102
torchmetrics                0.6.0
tornado                     6.1
tqdm                        4.62.3
traitlets                   5.1.1
typing_extensions           NA
wcwidth                     0.2.5
yaml                        5.4.1
zipp                        NA
zmq                         22.3.0
```

Example 6 (unknown):
```unknown
-----
IPython             7.29.0
jupyter_client      7.1.0
jupyter_core        4.9.1
notebook            6.4.6
-----
Python 3.7.11 (default, Jul 27 2021, 14:32:16) [GCC 7.5.0]
Linux-4.15.0-176-generic-x86_64-with-debian-buster-sid
-----
Session information updated at 2023-02-09 00:59
```

Example 7 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=80, facecolor='white', color_map = 'RdPu',)
```

Example 8 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/scVI/RNA_foetal_pp.h5ad')
adata
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 372801 × 3343
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'hvg'
    obsm: 'latent_gene_encoding'
    layers: 'counts'
```

Example 10 (python):
```python
print(adata)
print(adata.obs['batch_key'].value_counts())
print(adata.obs['cell_or_nuclei'].value_counts())
```

Example 11 (unknown):
```unknown
AnnData object with n_obs × n_vars = 372801 × 3343
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'hvg'
    obsm: 'latent_gene_encoding'
    layers: 'counts'
Hst41_Nuclei_Multiome-v1    129909
Hst33_Nuclei_Multiome-v1     62684
Hst39_Nuclei_Multiome-v1     30591
C99_Cell_5prime-v2           17921
C97_Cell_5prime-v2           17388
C92_Nuclei_Multiome-v1       15379
C94_Cell_5prime-v2           13971
Hst40_Nuclei_Multiome-v1     11559
BRC2251_Cell_3prime-v3        9651
BRC2256_Cell_3prime-v3        8525
BRC2260_Cell_3prime-v3        8408
Hst36_Nuclei_Multiome-v1      7848
BRC2252_Cell_3prime-v3        7366
C86_Cell_5prime-v2            6567
BRC2263_Cell_3prime-v3        5917
BRC2262_Cell_3prime-v3        4749
C87_Nuclei_Multiome-v1        4499
C104_Nuclei_Multiome-v1       3411
C98_Nuclei_Multiome-v1        3039
C85_Nuclei_Multiome-v1        2808
C82_Nuclei_Multiome-v1         611
Name: batch_key, dtype: int64
Nuclei    272338
Cell      100463
Name: cell_or_nuclei, dtype: int64
```

Example 12 (python):
```python
adata.layers['counts'].data[:10]
```

Example 13 (unknown):
```unknown
array([ 5.,  4., 20.,  1.,  1.,  4.,  4.,  3.,  1.,  2.], dtype=float32)
```

Example 14 (python):
```python
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])
```

Example 15 (python):
```python
INFO     Using batches from adata.obs["batch_key"]                                           
INFO     No label_key inputted, assuming all cells have same label                           
INFO     Using data from adata.layers["counts"]                                              
INFO     Successfully registered anndata object containing 372801 cells, 3343 vars, 21       
         batches, 1 labels, and 0 proteins. Also registered 0 extra categorical covariates   
         and 3 extra continuous covariates.                                                  
INFO     Please do not further modify adata until model is trained.
```

Example 16 (python):
```python
scvi.data.view_anndata_setup(adata)
```

Example 17 (unknown):
```unknown
/lustre/scratch117/cellgen/team205/kk18/miniconda3/envs/scvi_env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function view_anndata_setup is deprecated; This method will be removed in 0.15.0. Please avoid building any new dependencies on it.
  warnings.warn(msg, category=FutureWarning)
```

Example 18 (unknown):
```unknown
Anndata setup with scvi-tools version 0.14.5.
```

Example 19 (unknown):
```unknown
Data Summary               
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃             Data             ┃ Count  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━┩
│            Cells             │ 372801 │
│             Vars             │  3343  │
│            Labels            │   1    │
│           Batches            │   21   │
│           Proteins           │   0    │
│ Extra Categorical Covariates │   0    │
│ Extra Continuous Covariates  │   3    │
└──────────────────────────────┴────────┘
```

Example 20 (python):
```python
SCVI Data Registry                   
┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃     Data      ┃         scvi-tools Location          ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│       X       │        adata.layers['counts']        │
│ batch_indices │       adata.obs['_scvi_batch']       │
│    labels     │      adata.obs['_scvi_labels']       │
│   cont_covs   │ adata.obsm['_scvi_extra_continuous'] │
└───────────────┴──────────────────────────────────────┘
```

Example 21 (python):
```python
Label Categories                        
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 22 (python):
```python
Batch Categories                              
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃        Categories        ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │  BRC2251_Cell_3prime-v3  │          0          │
│                        │  BRC2252_Cell_3prime-v3  │          1          │
│                        │  BRC2256_Cell_3prime-v3  │          2          │
│                        │  BRC2260_Cell_3prime-v3  │          3          │
│                        │  BRC2262_Cell_3prime-v3  │          4          │
│                        │  BRC2263_Cell_3prime-v3  │          5          │
│                        │  C82_Nuclei_Multiome-v1  │          6          │
│                        │  C85_Nuclei_Multiome-v1  │          7          │
│                        │    C86_Cell_5prime-v2    │          8          │
│                        │  C87_Nuclei_Multiome-v1  │          9          │
│                        │  C92_Nuclei_Multiome-v1  │         10          │
│                        │    C94_Cell_5prime-v2    │         11          │
│                        │    C97_Cell_5prime-v2    │         12          │
│                        │  C98_Nuclei_Multiome-v1  │         13          │
│                        │    C99_Cell_5prime-v2    │         14          │
│                        │ C104_Nuclei_Multiome-v1  │         15          │
│                        │ Hst33_Nuclei_Multiome-v1 │         16          │
│                        │ Hst36_Nuclei_Multiome-v1 │         17          │
│                        │ Hst39_Nuclei_Multiome-v1 │         18          │
│                        │ Hst40_Nuclei_Multiome-v1 │         19          │
│                        │ Hst41_Nuclei_Multiome-v1 │         20          │
└────────────────────────┴──────────────────────────┴─────────────────────┘
```

Example 23 (python):
```python
Extra Continuous Variables                  
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃           Range            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │       1000 -> 727776       │
│  adata.obs['pct_counts_mt']  │ 0 -> 19.991365432739257812 │
│ adata.obs['pct_counts_ribo'] │ 0 -> 19.974821090698242188 │
└──────────────────────────────┴────────────────────────────┘
```

Example 24 (python):
```python
vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae
```

Example 25 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 3, dropout_rate: 0.1, dispersion: gene-batch, 
gene_likelihood: zinb, latent_distribution: normal
Training status: Not Trained
```

Example 26 (python):
```python
To print summary of associated AnnData, use: scvi.data.view_anndata_setup(model.adata)
```

Example 27 (unknown):
```unknown
# train
vae.train()
```

Example 28 (unknown):
```unknown
GPU available: True, used: True
TPU available: False, using: 0 TPU cores
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 29 (unknown):
```unknown
Epoch 21/21: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 21/21 [09:38<00:00, 27.55s/it, loss=954, v_num=1]
```

Example 30 (unknown):
```unknown
# save scvi model
vae.save("/nfs/team205/heart/anndata_objects/Foetal/scVI/models/RNA_foetal_global/",overwrite=True)
```

Example 31 (python):
```python
# vae = scvi.model.SCVI.load("/nfs/team205/heart/anndata_objects/Foetal/scVI/models/RNA_foetal_global/", adata)
```

Example 32 (python):
```python
# Convergency plot
vae.history['elbo_train']
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
```

Example 33 (python):
```python
adata.obsm["X_scVI"] = vae.get_latent_representation()
adata.write('/nfs/team205/heart/anndata_objects/Foetal/scVI/RNA_foetal_scVI.h5ad')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Endothelial/EndothelialCellCycleInvestigation.html

10685 rows × 1 columns

2691 rows × 51 columns

2691 rows × 7 columns

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-09-19 14:21.
```

Example 5 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
#adata = adata[adata.obs['fine_grain'].isin(['GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adata = adata[adata.obs['week'].isin(['4W','5W','6W','7W','8W'])].copy()
adata = adata[adata.obs['coarse_grain'].isin(['Endothelium'])].copy()
print(adata.shape)
```

Example 6 (unknown):
```unknown
(11063, 36601)
```

Example 7 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 8 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 9 (python):
```python
#Expression: "YlGn" (e.g. DE plots)
#Divergent expression: "PRGn" (e.g. log2FC)
#Age: "afmhot_r"
#Others: "viridis" (e.g. UMAP expression)

#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodePacemakerCells':'#854834',
    'AtrioventricularNodePacemakerCells':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParasympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 10 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)

sc.pl.umap(adata, color='fine_grain')
sc.pl.umap(adata, color='cycling')

sc.tl.diffmap(adata)
sc.pl.diffmap(adata, color='fine_grain')
sc.pl.diffmap(adata, color='cycling')

# PAGA graph construction
sc.tl.paga(adata, groups='fine_grain')
plt.rcParams["figure.figsize"] = [6, 4.5]
sc.pl.paga(adata,frameon=False)
sc.tl.draw_graph(adata, init_pos='paga', random_state=123)
sc.pl.draw_graph(adata, color='fine_grain')
sc.pl.draw_graph(adata, color='cycling')
```

Example 11 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:06)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
2794
```

Example 12 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'UNG', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    536 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'ANP32E', 'CDC25C', 'RANGAP1', 'CDCA2', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    820 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 13 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 14 (unknown):
```unknown
Epoch 50/50: 100%|███████| 50/50 [01:08<00:00,  1.36s/it, loss=1.2e+03, v_num=1]
```

Example 15 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    393 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    294 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:02)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:03)
```

Example 16 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 17 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 18 (python):
```python
computing Diffusion Maps using n_comps=15(=n_dcs)
computing transitions
    finished (0:00:00)
    eigenvalues of transition matrix
    [1.         0.99813575 0.99639726 0.99591756 0.9939016  0.99028945
     0.9895821  0.98796153 0.9864883  0.98519886 0.9835595  0.9803847
     0.9789236  0.97758424 0.97680676]
    finished: added
    'X_diffmap', diffmap coordinates (adata.obsm)
    'diffmap_evals', eigenvalues of transition matrix (adata.uns) (0:00:00)
```

Example 19 (python):
```python
running PAGA
    finished: added
    'paga/connectivities', connectivities adjacency (adata.uns)
    'paga/connectivities_tree', connectivities subtree (adata.uns) (0:00:00)
--> added 'pos', the PAGA positions (adata.uns['paga'])
```

Example 20 (unknown):
```unknown
drawing single-cell graph using layout 'fa'
```

Example 21 (python):
```python
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/tmp/ipykernel_143680/25561144.py in <module>
     68 plt.rcParams["figure.figsize"] = [6, 4.5]
     69 sc.pl.paga(adata,frameon=False)
---> 70 sc.tl.draw_graph(adata, init_pos='paga', random_state=123)
     71 sc.pl.draw_graph(adata, color='fine_grain')
     72 sc.pl.draw_graph(adata, color='cycling')

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/tools/_draw_graph.py in draw_graph(adata, layout, init_pos, root, random_state, n_jobs, adjacency, key_added_ext, neighbors_key, obsp, copy, **kwds)
    157         else:
    158             iterations = 500
--> 159         positions = forceatlas2.forceatlas2(
    160             adjacency, pos=init_coords, iterations=iterations
    161         )

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/fa2/forceatlas2.py in forceatlas2(self, G, pos, iterations)
    197             # parallelization should be implemented here
    198             if self.barnesHutOptimize:
--> 199                 rootRegion.applyForceOnNodes(nodes, self.barnesHutTheta, self.scalingRatio)
    200             else:
    201                 fa2util.apply_repulsion(nodes, self.scalingRatio)

KeyboardInterrupt:
```

Example 22 (python):
```python
#bdata=adata.copy()
#adata=bdata.copy()
```

Example 23 (unknown):
```unknown
new annotation
original annotation
barcode
```

Example 24 (python):
```python
sc.pl.umap(adata, color='fine_grain')
```

Example 25 (python):
```python
set(adata.obs.fine_grain)
```

Example 26 (unknown):
```unknown
{'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryVenousEndothelialCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselVenousEndothelialCells',
 'LymphaticEndothelialCells',
 'ValveEndothelialCells'}
```

Example 27 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['EndocardialCushionCells','EndocardialCells','ValveEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','CoronaryArterialEndothelialCells'])].copy()
```

Example 28 (python):
```python
sc.pl.umap(adata, color='fine_grain')
```

Example 29 (python):
```python
sc.tl.leiden(adata, resolution=0.75, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 30 (python):
```python
running Leiden clustering
    finished: found 19 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 31 (python):
```python
adata.obs['SVannotation']= 'na'

adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['CoronaryArterialEndothelialCells']]]='CoronaryArterialEndothelialCells'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselArterialEndothelialCells']]]='GreatVesselEndothelialCells'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['EndocardialCushionCells','EndocardialCells','ValveEndothelialCells']]]='EndocardialCells'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['CoronaryCapillaryEndothelialCells']]]='CoronaryCapillary1'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.leiden[x] in ['17']]]='CoronaryCapillary2'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselVenousEndothelialCells','CoronaryVenousEndothelialCells']]]='ProgenitorCells'
sc.pl.umap(adata, color='SVannotation')
sc.pl.umap(adata, color='fine_grain')
```

Example 32 (unknown):
```unknown
... storing 'SVannotation' as categorical
```

Example 33 (python):
```python
ClusterOfInterest='17'
#sc.tl.rank_genes_groups(adata, 'leiden', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='leiden',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 34 (python):
```python
sc.pl.umap(adata, color='cycling')
```

Example 35 (python):
```python
#New annotations for SV investigation

adata.obs['SVannotation']= 'na'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselVenousEndothelialCells','CoronaryVenousEndothelialCells']]]='ProgenitorCells'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['CoronaryCapillaryEndothelialCells','CoronaryArterialEndothelialCells']]]='CoronaryEndothelialCells'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselArterialEndothelialCells']]]='GreatVesselEndothelialCells'
adata.obs['SVannotation'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['EndocardialCushionCells','EndocardialCells','ValveEndothelialCells']]]='EndocardialCells'
sc.pl.umap(adata, color='SVannotation')
```

Example 36 (unknown):
```unknown
... storing 'SVannotation' as categorical
```

Example 37 (python):
```python
sc.pl.umap(adata, color='ACKR1')
```

Example 38 (python):
```python
metadata=[]
for k in range(0,10685):
    a=adata.obs_names[k]+' , '+adata.obs.SVannotation[k]+' , '+adata.obs.fine_grain[k]+' , '+adata.obs.donor[k]
    metadata.append(a)
    
b=pd.DataFrame(metadata)
b.to_csv('SVTracingAnnotation.csv')
```

Example 39 (unknown):
```unknown
#trials for running RNA velocity
```

Example 40 (python):
```python
#G4
adataG4=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataG4 = adataG4[adataG4.obs['donor'].isin(['BRC2251'])].copy()
adataG4 = adataG4[adataG4.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataG4 = adataG4[adataG4.obs['region'].isin(['apex'])].copy()
print(adataG4.shape)
barcodes = adataG4.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_G4' for bc in barcodes]
adataG4.obs.index=barcodes
adataG4.var_names_make_unique()
ldataG4=scv.read('./LoomFiles/G4.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataG4.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_G4' for bc in barcodes]
ldataG4.obs.index = barcodes
ldataG4.var_names_make_unique()
ldataG4=ldataG4[[x for x in ldataG4.obs_names if x in adataG4.obs_names],:].copy()
print(len(ldataG4.obs_names))

#F4
adataF4=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataF4 = adataF4[adataF4.obs['donor'].isin(['BRC2251'])].copy()
adataF4 = adataF4[adataF4.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataF4 = adataF4[adataF4.obs['region'].isin(['base'])].copy()
print(adataF4.shape)
barcodes = adataF4.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_F4' for bc in barcodes]
adataF4.obs.index=barcodes
adataF4.var_names_make_unique()
ldataF4=scv.read('./LoomFiles/F4.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataF4.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_F4' for bc in barcodes]
ldataF4.obs.index = barcodes
ldataF4.var_names_make_unique()
ldataF4=ldataF4[[x for x in ldataF4.obs_names if x in adataF4.obs_names],:].copy()
print(len(ldataF4.obs_names))

#D8
adataD8=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataD8 = adataD8[adataD8.obs['donor'].isin(['BRC2253'])].copy()
adataD8 = adataD8[adataD8.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataD8 = adataD8[adataD8.obs['region'].isin(['apex'])].copy()
print(adataD8.shape)
barcodes = adataD8.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_D8' for bc in barcodes]
adataD8.obs.index=barcodes
adataD8.var_names_make_unique()
ldataD8=scv.read('./LoomFiles/D8.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataD8.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_D8' for bc in barcodes]
ldataD8.obs.index = barcodes
ldataD8.var_names_make_unique()
ldataD8=ldataD8[[x for x in ldataD8.obs_names if x in adataD8.obs_names],:].copy()
print(len(ldataD8.obs_names))

#C8
adataC8=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataC8 = adataC8[adataC8.obs['donor'].isin(['BRC2253'])].copy()
adataC8 = adataC8[adataC8.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataC8 = adataC8[adataC8.obs['region'].isin(['base'])].copy()
print(adataC8.shape)
barcodes = adataC8.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_C8' for bc in barcodes]
adataC8.obs.index=barcodes
adataC8.var_names_make_unique()
ldataC8=scv.read('./LoomFiles/C8.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataC8.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_C8' for bc in barcodes]
ldataC8.obs.index = barcodes
ldataC8.var_names_make_unique()
ldataC8=ldataC8[[x for x in ldataC8.obs_names if x in adataC8.obs_names],:].copy()
print(len(ldataC8.obs_names))

#F8
adataF8=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataF8 = adataF8[adataF8.obs['donor'].isin(['BRC2256'])].copy()
adataF8 = adataF8[adataF8.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataF8 = adataF8[adataF8.obs['region'].isin(['apex'])].copy()
print(adataF8.shape)
barcodes = adataF8.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_F8' for bc in barcodes]
adataF8.obs.index=barcodes
adataF8.var_names_make_unique()
ldataF8=scv.read('./LoomFiles/F8.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataF8.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_F8' for bc in barcodes]
ldataF8.obs.index = barcodes
ldataF8.var_names_make_unique()
ldataF8=ldataF8[[x for x in ldataF8.obs_names if x in adataF8.obs_names],:].copy()
print(len(ldataF8.obs_names))

#E8
adataE8=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataE8 = adataE8[adataE8.obs['donor'].isin(['BRC2256'])].copy()
adataE8 = adataE8[adataE8.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataE8 = adataE8[adataE8.obs['region'].isin(['base'])].copy()
print(adataE8.shape)
barcodes = adataE8.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_E8' for bc in barcodes]
adataE8.obs.index=barcodes
adataE8.var_names_make_unique()
ldataE8=scv.read('./LoomFiles/E8.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataE8.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_E8' for bc in barcodes]
ldataE8.obs.index = barcodes
ldataE8.var_names_make_unique()
ldataE8=ldataE8[[x for x in ldataE8.obs_names if x in adataE8.obs_names],:].copy()
print(len(ldataE8.obs_names))

#F2
adataF2=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataF2 = adataF2[adataF2.obs['donor'].isin(['BRC2260'])].copy()
adataF2 = adataF2[adataF2.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataF2 = adataF2[adataF2.obs['region'].isin(['apex'])].copy()
print(adataF2.shape)
barcodes = adataF2.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_F2' for bc in barcodes]
adataF2.obs.index=barcodes
adataF2.var_names_make_unique()
ldataF2=scv.read('./LoomFiles/F2.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataF2.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_F2' for bc in barcodes]
ldataF2.obs.index = barcodes
ldataF2.var_names_make_unique()
ldataF2=ldataF2[[x for x in ldataF2.obs_names if x in adataF2.obs_names],:].copy()
print(len(ldataF2.obs_names))

#E2
adataE2=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataE2 = adataE2[adataE2.obs['donor'].isin(['BRC2260'])].copy()
adataE2 = adataE2[adataE2.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataE2 = adataE2[adataE2.obs['region'].isin(['base'])].copy()
print(adataE2.shape)
barcodes = adataE2.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_E2' for bc in barcodes]
adataE2.obs.index=barcodes
adataE2.var_names_make_unique()
ldataE2=scv.read('./LoomFiles/E2.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataE2.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_E2' for bc in barcodes]
ldataE2.obs.index = barcodes
ldataE2.var_names_make_unique()
ldataE2=ldataE2[[x for x in ldataE2.obs_names if x in adataE2.obs_names],:].copy()
print(len(ldataE2.obs_names))

#B1
adataB1=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataB1 = adataB1[adataB1.obs['donor'].isin(['BRC2262'])].copy()
adataB1 = adataB1[adataB1.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataB1 = adataB1[adataB1.obs['region'].isin(['apex'])].copy()
print(adataB1.shape)
barcodes = adataB1.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_B1' for bc in barcodes]
adataB1.obs.index=barcodes
adataB1.var_names_make_unique()
ldataB1=scv.read('./LoomFiles/B1.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataB1.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_B1' for bc in barcodes]
ldataB1.obs.index = barcodes
ldataB1.var_names_make_unique()
ldataB1=ldataB1[[x for x in ldataB1.obs_names if x in adataB1.obs_names],:].copy()
print(len(ldataB1.obs_names))

#A1
adataA1=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataA1 = adataA1[adataA1.obs['donor'].isin(['BRC2262'])].copy()
adataA1 = adataA1[adataA1.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataA1 = adataA1[adataA1.obs['region'].isin(['base'])].copy()
print(adataA1.shape)
barcodes = adataA1.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_A1' for bc in barcodes]
adataA1.obs.index=barcodes
adataA1.var_names_make_unique()
ldataA1=scv.read('./LoomFiles/A1.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataA1.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_A1' for bc in barcodes]
ldataA1.obs.index = barcodes
ldataA1.var_names_make_unique()
ldataA1=ldataA1[[x for x in ldataA1.obs_names if x in adataA1.obs_names],:].copy()
print(len(ldataA1.obs_names))

#G7
adataG7=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataG7 = adataG7[adataG7.obs['donor'].isin(['BRC2263'])].copy()
adataG7 = adataG7[adataG7.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataG7 = adataG7[adataG7.obs['region'].isin(['apex'])].copy()
print(adataG7.shape)
barcodes = adataG7.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_G7' for bc in barcodes]
adataG7.obs.index=barcodes
adataG7.var_names_make_unique()
ldataG7=scv.read('./LoomFiles/G7.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataG7.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_G7' for bc in barcodes]
ldataG7.obs.index = barcodes
ldataG7.var_names_make_unique()
ldataG7=ldataG7[[x for x in ldataG7.obs_names if x in adataG7.obs_names],:].copy()
print(len(ldataG7.obs_names))

#F7
adataF7=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adataF7 = adataF7[adataF7.obs['donor'].isin(['BRC2263'])].copy()
adataF7 = adataF7[adataF7.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adataF7 = adataF7[adataF7.obs['region'].isin(['base'])].copy()
print(adataF7.shape)
barcodes = adataF7.obs.index.tolist()
barcodes = [bc[9:len(bc)-2]+'_F7' for bc in barcodes]
adataF7.obs.index=barcodes
adataF7.var_names_make_unique()
ldataF7=scv.read('./LoomFiles/F7.loom', cache=True)
barcodes = [bc.split(':')[1] for bc in ldataF7.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] +'_F7' for bc in barcodes]
ldataF7.obs.index = barcodes
ldataF7.var_names_make_unique()
ldataF7=ldataF7[[x for x in ldataF7.obs_names if x in adataF7.obs_names],:].copy()
print(len(ldataF7.obs_names))

CSCIadata=adataG4.concatenate(adataF4,adataD8,adataC8,adataF8,adataE8,adataF2,adataE2,adataB1,adataA1,adataG7,adataF7)
ldata=ldataG4.concatenate([ldataF4,ldataD8,ldataC8,ldataF8,ldataE8,ldataF2,ldataE2,ldataB1,ldataA1,ldataG7,ldataF7])

#D8: BRC2253, apex
#C8: BRC2253, base\
#F8: BRC2256, apex
#E8: BRC2256, base
#F2: BRC2260, apex
#E2: BRC2260, base
#B1: BRC2262, apex
#A1: BRC2262, base
#G7: BRC2263, apex
#F7: BRC2263, base
```

Example 41 (python):
```python
(111, 36601)
... reading from cache file cache/LoomFiles-G4.h5ad
```

Example 42 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 43 (python):
```python
111
(256, 36601)
... reading from cache file cache/LoomFiles-F4.h5ad
```

Example 44 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 45 (python):
```python
252
(87, 36601)
... reading from cache file cache/LoomFiles-D8.h5ad
```

Example 46 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 47 (python):
```python
87
(81, 36601)
... reading from cache file cache/LoomFiles-C8.h5ad
```

Example 48 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 49 (python):
```python
81
(113, 36601)
... reading from cache file cache/LoomFiles-F8.h5ad
```

Example 50 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 51 (python):
```python
113
(433, 36601)
... reading from cache file cache/LoomFiles-E8.h5ad
```

Example 52 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 53 (python):
```python
433
(368, 36601)
... reading from cache file cache/LoomFiles-F2.h5ad
```

Example 54 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 55 (python):
```python
368
(517, 36601)
... reading from cache file cache/LoomFiles-E2.h5ad
```

Example 56 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 57 (python):
```python
517
(149, 36601)
... reading from cache file cache/LoomFiles-B1.h5ad
```

Example 58 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 59 (python):
```python
149
(163, 36601)
... reading from cache file cache/LoomFiles-A1.h5ad
```

Example 60 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 61 (python):
```python
163
(124, 36601)
... reading from cache file cache/LoomFiles-G7.h5ad
```

Example 62 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 63 (python):
```python
124
(295, 36601)
... reading from cache file cache/LoomFiles-F7.h5ad
```

Example 64 (unknown):
```unknown
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
```

Example 65 (python):
```python
CSCIadata=adataG4.concatenate(adataF4,adataD8,adataC8,adataF8,adataE8,adataF2,adataE2,adataB1,adataA1,adataG7,adataF7)
ldata=ldataG4.concatenate([ldataF4,ldataD8,ldataC8,ldataF8,ldataE8,ldataF2,ldataE2,ldataB1,ldataA1,ldataG7,ldataF7])
```

Example 66 (python):
```python
# reduced barcode names 
barcodes = CSCIadata.obs.index.tolist()
barcodes = [bc[0:19] for bc in barcodes]
CSCIadata.obs.index=barcodes

barcodes = ldata.obs.index.tolist()
barcodes = [bc[0:19] for bc in barcodes]
ldata.obs.index=barcodes
ldata.obs_names
```

Example 67 (unknown):
```unknown
Index(['AACGGGAGTACGATGG_G4', 'AAGAACAGTGATACAA_G4', 'AAGCCATCAGCTCTGG_G4',
       'ACACTGACACAAAGTA_G4', 'ACGATCATCATTACCT_G4', 'ACAGCCGTCACCCTGT_G4',
       'ACAAGCTGTGGATTTC_G4', 'ACTTCGCCATGTGCTA_G4', 'AGATCCATCAAACGTC_G4',
       'AGAACAAAGCACTCAT_G4',
       ...
       'TTGGGATAGCATCAAA_F7', 'TTGCTGCCACTGCACG_F7', 'TTGCATTTCACCTGGG_F7',
       'TTGTTGTGTGATGTAA_F7', 'TTGTGGAAGCTAGTTC_F7', 'TTTGGTTGTATCGTGT_F7',
       'TTTCGATTCAGACCGC_F7', 'TTTGGAGAGGCAGGGA_F7', 'TTTGGAGTCACCGGGT_F7',
       'TTTAGTCCAAGCAGGT_F7'],
      dtype='object', length=2691)
```

Example 68 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adata = adata[adata.obs['facility'].isin(['Sanger'])].copy()
adata=adata.concatenate(CSCIadata)
```

Example 69 (unknown):
```unknown
(297473, 36601)
```

Example 70 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)

sc.pl.umap(adata, color='fine_grain')
sc.pl.umap(adata, color='cycling')

sc.tl.diffmap(adata)
sc.pl.diffmap(adata, color='fine_grain')
sc.pl.diffmap(adata, color='cycling')

# PAGA graph construction
sc.tl.paga(adata, groups='fine_grain')
plt.rcParams["figure.figsize"] = [6, 4.5]
sc.pl.paga(adata,frameon=False)
sc.tl.draw_graph(adata, init_pos='paga', random_state=123)
sc.pl.draw_graph(adata, color='fine_grain')
sc.pl.draw_graph(adata, color='cycling')
```

Example 71 (unknown):
```unknown
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
```

Example 72 (unknown):
```unknown
... storing 'sangerID' as categorical
... storing 'combinedID' as categorical
... storing 'donor' as categorical
... storing 'region' as categorical
... storing 'age' as categorical
... storing 'facility' as categorical
... storing 'cell_or_nuclei' as categorical
... storing 'modality' as categorical
... storing 'kit_10x' as categorical
... storing 'donor_by_library-prep' as categorical
... storing 'multiplexed' as categorical
... storing 'SOC | status' as categorical
... storing 'batch_key' as categorical
... storing 'FACSgate' as categorical
... storing 'fine_grain' as categorical
... storing 'sex' as categorical
... storing 'week' as categorical
... storing 'trimester' as categorical
```

Example 73 (python):
```python
finished (0:00:08)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1332
```

Example 74 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'MCM2', 'MCM4', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'UHRF1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    329 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'CKAP2L', 'ANP32E', 'HJURP', 'CDCA3', 'NCAPD2', 'CDCA2', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    729 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 75 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 76 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:31<00:00,  1.60it/s, loss=667, v_num=1]
```

Example 77 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    479 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBE1', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    244 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:02)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:05)
```

Example 78 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 79 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 80 (python):
```python
computing Diffusion Maps using n_comps=15(=n_dcs)
computing transitions
    finished (0:00:00)
    eigenvalues of transition matrix
    [1.         0.99514455 0.9879886  0.984966   0.9805877  0.9780712
     0.97638977 0.9711257  0.9674525  0.96672106 0.9656661  0.95888704
     0.9573041  0.9536183  0.95201683]
    finished: added
    'X_diffmap', diffmap coordinates (adata.obsm)
    'diffmap_evals', eigenvalues of transition matrix (adata.uns) (0:00:00)
```

Example 81 (python):
```python
running PAGA
    finished: added
    'paga/connectivities', connectivities adjacency (adata.uns)
    'paga/connectivities_tree', connectivities subtree (adata.uns) (0:00:00)
--> added 'pos', the PAGA positions (adata.uns['paga'])
```

Example 82 (python):
```python
drawing single-cell graph using layout 'fa'
    finished: added
    'X_draw_graph_fa', graph_drawing coordinates (adata.obsm) (0:00:36)
```

Example 83 (python):
```python
#bdata=adata.copy()
```

Example 84 (python):
```python
adata=bdata.copy()
adata
```

Example 85 (unknown):
```unknown
AnnData object with n_obs × n_vars = 8375 × 1332
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'batch'
    var: 'gene_id', 'gene_name_scRNA-0', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'log1p', 'hvg', '_scvi_uuid', '_scvi_manager_uuid', 'neighbors', 'umap', 'phase_colors', 'donor_colors', 'age_colors', 'week_colors', 'trimester_colors', 'region_colors', 'cycling_colors', 'cell_or_nuclei_colors', 'modality_colors', 'kit_10x_colors', 'FACSgate_colors', 'heart_or_greatvessels_colors', 'coarse_grain_colors', 'mid_grain_colors', 'fine_grain_colors', 'diffmap_evals', 'paga', 'fine_grain_sizes', 'draw_graph'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding', 'X_diffmap', 'X_draw_graph_fa'
    layers: 'counts'
    obsp: 'distances', 'connectivities'
```

Example 86 (python):
```python
adata.obs_names
```

Example 87 (unknown):
```unknown
Index(['BHF_F_Hea10402917_TGGCTGGGTTGTGGAG-1-0',
       'BHF_F_Hea10402917_TTTGGTTTCTTTCCTC-1-0',
       'BHF_F_Hea10402917_TGCTGCTCAGTATCTG-1-0',
       'BHF_F_Hea10402917_TCGTAGATCCTATTCA-1-0',
       'BHF_F_Hea10402917_TGGCTGGAGACGCTTT-1-0',
       'BHF_F_Hea10402917_AGAATAGTCTGCAAGT-1-0',
       'BHF_F_Hea10402917_GATCGCGTCATTGCGA-1-0',
       'BHF_F_Hea10402917_ACAGCTATCGGTCTAA-1-0',
       'BHF_F_Hea10402917_GTCGGGTCAAGCCCAC-1-0',
       'BHF_F_Hea10402917_GTCTTCGCATCCCATC-1-0',
       ...
       'GGTCTGGCAAGAGATT_F7-1', 'AGAAGCGTCAGATTGC_F7-1',
       'CACGTTCCAATGGCCC_F7-1', 'CCATAAGTCAAGGAGC_F7-1',
       'TGTAGACCAAAGAACT_F7-1', 'TTCCTCTAGGCACCAA_F7-1',
       'TGCAGGCTCGGTTCAA_F7-1', 'GTTGCTCAGGTTACCT_F7-1',
       'TGGGAAGCAGAGCGTA_F7-1', 'ATCGTAGCAAGTGCAG_F7-1'],
      dtype='object', length=8375)
```

Example 88 (python):
```python
adata=adata[adata.obs.facility=='CSCI',:].copy()
```

Example 89 (python):
```python
adata.obs_names
```

Example 90 (unknown):
```unknown
Index(['CTTCTCTAGCCTCAAT_G4-1', 'CATGCAATCTGAGATC_G4-1',
       'TTTATGCTCCTAACAG_G4-1', 'CAGCACGCAATCGCAT_G4-1',
       'AGAAGCGTCTACTGAG_G4-1', 'TCAAGTGCACTACAGT_G4-1',
       'CCGGGTAAGAGTTGAT_G4-1', 'TTTACCACAGCTGAAG_G4-1',
       'TTGATGGGTCTACAAC_G4-1', 'TAGACCATCCTACTGC_G4-1',
       ...
       'GGTCTGGCAAGAGATT_F7-1', 'AGAAGCGTCAGATTGC_F7-1',
       'CACGTTCCAATGGCCC_F7-1', 'CCATAAGTCAAGGAGC_F7-1',
       'TGTAGACCAAAGAACT_F7-1', 'TTCCTCTAGGCACCAA_F7-1',
       'TGCAGGCTCGGTTCAA_F7-1', 'GTTGCTCAGGTTACCT_F7-1',
       'TGGGAAGCAGAGCGTA_F7-1', 'ATCGTAGCAAGTGCAG_F7-1'],
      dtype='object', length=2697)
```

Example 91 (python):
```python
barcodes = adata.obs.index.tolist()
barcodes = [bc[0:19] for bc in barcodes]
adata.obs.index=barcodes
```

Example 92 (python):
```python
adata.obs_names
```

Example 93 (unknown):
```unknown
Index(['CTTCTCTAGCCTCAAT_G4', 'CATGCAATCTGAGATC_G4', 'TTTATGCTCCTAACAG_G4',
       'CAGCACGCAATCGCAT_G4', 'AGAAGCGTCTACTGAG_G4', 'TCAAGTGCACTACAGT_G4',
       'CCGGGTAAGAGTTGAT_G4', 'TTTACCACAGCTGAAG_G4', 'TTGATGGGTCTACAAC_G4',
       'TAGACCATCCTACTGC_G4',
       ...
       'GGTCTGGCAAGAGATT_F7', 'AGAAGCGTCAGATTGC_F7', 'CACGTTCCAATGGCCC_F7',
       'CCATAAGTCAAGGAGC_F7', 'TGTAGACCAAAGAACT_F7', 'TTCCTCTAGGCACCAA_F7',
       'TGCAGGCTCGGTTCAA_F7', 'GTTGCTCAGGTTACCT_F7', 'TGGGAAGCAGAGCGTA_F7',
       'ATCGTAGCAAGTGCAG_F7'],
      dtype='object', length=2697)
```

Example 94 (unknown):
```unknown
ldata.obs_names
```

Example 95 (unknown):
```unknown
Index(['AACGGGAGTACGATGG_G4', 'AAGAACAGTGATACAA_G4', 'AAGCCATCAGCTCTGG_G4',
       'ACACTGACACAAAGTA_G4', 'ACGATCATCATTACCT_G4', 'ACAGCCGTCACCCTGT_G4',
       'ACAAGCTGTGGATTTC_G4', 'ACTTCGCCATGTGCTA_G4', 'AGATCCATCAAACGTC_G4',
       'AGAACAAAGCACTCAT_G4',
       ...
       'TTGGGATAGCATCAAA_F7', 'TTGCTGCCACTGCACG_F7', 'TTGCATTTCACCTGGG_F7',
       'TTGTTGTGTGATGTAA_F7', 'TTGTGGAAGCTAGTTC_F7', 'TTTGGTTGTATCGTGT_F7',
       'TTTCGATTCAGACCGC_F7', 'TTTGGAGAGGCAGGGA_F7', 'TTTGGAGTCACCGGGT_F7',
       'TTTAGTCCAAGCAGGT_F7'],
      dtype='object', length=2691)
```

Example 96 (python):
```python
a=list(set(adata.obs_names))
b=list(set(ldata.obs_names))
BarcodesToRemove=a+b
BarcodesToRemove=list(set([x for x in BarcodesToRemove if BarcodesToRemove.count(x) == 1]))
BarcodesToRemove
```

Example 97 (unknown):
```unknown
['GCCCAGATCGACGAGA_F4',
 'TGCAGGCAGCACGGAT_F4',
 'ATGACCATCTACCCAC_F4',
 'TGTAAGCGTAGCCAGA_F7',
 'CCACTTGAGAAGATCT_F4',
 'ACATCCCAGCTTCTAG_F7']
```

Example 98 (python):
```python
adata=adata[~adata.obs.index.isin(c)]
adata
```

Example 99 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 2691 × 1332
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'batch'
    var: 'gene_id', 'gene_name_scRNA-0', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'log1p', 'hvg', '_scvi_uuid', '_scvi_manager_uuid', 'neighbors', 'umap', 'phase_colors', 'donor_colors', 'age_colors', 'week_colors', 'trimester_colors', 'region_colors', 'cycling_colors', 'cell_or_nuclei_colors', 'modality_colors', 'kit_10x_colors', 'FACSgate_colors', 'heart_or_greatvessels_colors', 'coarse_grain_colors', 'mid_grain_colors', 'fine_grain_colors', 'diffmap_evals', 'paga', 'fine_grain_sizes', 'draw_graph'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding', 'X_diffmap', 'X_draw_graph_fa'
    layers: 'counts'
    obsp: 'distances', 'connectivities'
```

Example 100 (python):
```python
sc.pl.diffmap(adata, color=['NR2F2','RGCC','HEY2','cycling','fine_grain'], ncols=5)
```

Example 101 (python):
```python
sc.pl.dotplot(adata, ['KLF2','SOD1','KLF4','THBD','NOS3'] ,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 102 (python):
```python
adata = scv.utils.merge(adata, ldata)

scv.logging.print_version()
scv.settings.verbosity = 3  # show errors(0), warnings(1), info(2), hints(3)
scv.settings.presenter_view = True  # set max width size for presenter view
scv.set_figure_params('scvelo')  # for beautified visualization

###BASICS

scv.pl.proportions(adata)

scv.pp.filter_genes(adata, min_shared_counts=20)
scv.pp.normalize_per_cell(adata)
scv.pp.filter_genes_dispersion(adata, n_top_genes=len(adata.var_names))
scv.pp.log1p(adata)
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=len(adata.var_names))
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)

scv.tl.velocity(adata)
scv.tl.velocity_graph(adata)
scv.pl.velocity_embedding(adata, basis='diffmap')
scv.pl.velocity_embedding_grid(adata, basis='diffmap')
scv.pl.velocity_embedding_stream(adata, basis='diffmap')
scv.pl.velocity_embedding_stream(adata, basis='diffmap',color='fine_grain',palette=('Set2'),arrow_color='darkslategray')
scv.pl.velocity_embedding_stream(adata, basis='diffmap',color='cycling',palette=('Set2'),arrow_color='darkslategray')
scv.pl.velocity_embedding(adata, arrow_length=3, arrow_size=2, dpi=120)
```

Example 103 (python):
```python
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_79139/1646599308.py in <module>
----> 1 adata = scv.utils.merge(adata, ldata)
      2 
      3 scv.logging.print_version()
      4 scv.settings.verbosity = 3  # show errors(0), warnings(1), info(2), hints(3)
      5 scv.settings.presenter_view = True  # set max width size for presenter view

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scvelo/core/_anndata.py in merge(adata, ldata, copy)
    507     """
    508 
--> 509     adata.var_names_make_unique()
    510     ldata.var_names_make_unique()
    511 

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/anndata.py in var_names_make_unique(self, join)
   1801     def var_names_make_unique(self, join: str = "-"):
   1802         # Important to go through the setter so obsm dataframes are updated too
-> 1803         self.var_names = utils.make_index_unique(self.var.index, join)
   1804 
   1805     var_names_make_unique.__doc__ = utils.make_index_unique.__doc__

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/anndata.py in var_names(self, names)
    890     def var_names(self, names: Sequence[str]):
    891         names = self._prep_dim_index(names, "var")
--> 892         self._set_dim_index(names, "var")
    893 
    894     @property

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/anndata.py in _set_dim_index(self, value, attr)
    840         # Assumes _prep_dim_index has been run
    841         if self.is_view:
--> 842             self._init_as_actual(self.copy())
    843         getattr(self, attr).index = value
    844         for v in getattr(self, f"{attr}m").values():

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/anndata.py in copy(self, filename)
   1511             else:
   1512                 X = self.X.copy()
-> 1513             return self._mutated_copy(X=X)
   1514         else:
   1515             from .._io import read_h5ad

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/anndata.py in _mutated_copy(self, **kwargs)
   1453                 new[key] = kwargs[key]
   1454             else:
-> 1455                 new[key] = getattr(self, key).copy()
   1456         if "X" in kwargs:
   1457             new["X"] = kwargs["X"]

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/aligned_mapping.py in copy(self)
     85         d = self._actual_class(self.parent, self._axis)
     86         for k, v in self.items():
---> 87             d[k] = v.copy()
     88         return d
     89 

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/aligned_mapping.py in __setitem__(self, key, value)
    149 
    150     def __setitem__(self, key: str, value: V):
--> 151         value = self._validate_value(value, key)
    152         self._data[key] = value
    153 

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/aligned_mapping.py in _validate_value(self, val, key)
    210         ):
    211             # Could probably also re-order index if it’s contained
--> 212             raise ValueError(
    213                 f"value.index does not match parent’s axis {self.axes[0]} names"
    214             )

ValueError: value.index does not match parent’s axis 0 names
```

Example 104 (python):
```python
adata = scv.utils.merge(processeddata, ldata)

scv.logging.print_version()
scv.settings.verbosity = 3  # show errors(0), warnings(1), info(2), hints(3)
scv.settings.presenter_view = True  # set max width size for presenter view
scv.set_figure_params('scvelo')  # for beautified visualization

###BASICS

scv.pl.proportions(adata)

scv.pp.filter_genes(adata, min_shared_counts=20)
scv.pp.normalize_per_cell(adata)
scv.pp.filter_genes_dispersion(adata, n_top_genes=len(adata.var_names))
scv.pp.log1p(adata)
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=len(adata.var_names))
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)

scv.tl.velocity(adata)
scv.tl.velocity_graph(adata)
scv.pl.velocity_embedding(adata, basis='umap')
scv.pl.velocity_embedding_grid(adata, basis='umap')
scv.pl.velocity_embedding_stream(adata, basis='umap')
scv.pl.velocity_embedding_stream(adata, basis='umap',color='fine_grain',palette=('Set2'),arrow_color='darkslategray')
scv.pl.velocity_embedding_stream(adata, basis='umap',color='cycling',palette=('Set2'),arrow_color='darkslategray')
scv.pl.velocity_embedding(adata, arrow_length=3, arrow_size=2, dpi=120)
```

Example 105 (unknown):
```unknown
Running scvelo 0.2.4 (python 3.8.11) on 2023-08-31 09:11.
```

Example 106 (unknown):
```unknown
ERROR: XMLRPC request failed [code: -32500]
RuntimeError: PyPI no longer supports 'pip search' (or XML-RPC search). Please use https://pypi.org/search (via a browser) instead. See https://warehouse.pypa.io/api-reference/xml-rpc.html#deprecated-methods for more information.
```

Example 107 (python):
```python
Filtered out 1183 genes that are detected 20 counts (shared).
WARNING: Did not normalize X as it looks processed already. To enforce normalization, set `enforce=True`.
Normalized count data: spliced, unspliced.
Extracted 2490 highly variable genes.
Filtered out 591 genes that are detected 20 counts (shared).
WARNING: Did not normalize X as it looks processed already. To enforce normalization, set `enforce=True`.
WARNING: Did not normalize spliced as it looks processed already. To enforce normalization, set `enforce=True`.
WARNING: Did not normalize unspliced as it looks processed already. To enforce normalization, set `enforce=True`.
Skip filtering by dispersion since number of variables are less than `n_top_genes`.
WARNING: Did not modify X as it looks preprocessed already.
computing PCA
    on highly variable genes
    with n_comps=30
    finished (0:00:00)
computing neighbors
    finished (0:00:00) --> added 
    'distances' and 'connectivities', weighted adjacency matrices (adata.obsp)
computing moments based on connectivities
    finished (0:00:00) --> added 
    'Ms' and 'Mu', moments of un/spliced abundances (adata.layers)
computing velocities
    finished (0:00:00) --> added 
    'velocity', velocity vectors for each individual cell (adata.layers)
computing velocity graph (using 1/32 cores)
```

Example 108 (unknown):
```unknown
0%|          | 0/2691 [00:00<?, ?cells/s]
```

Example 109 (python):
```python
finished (0:00:03) --> added 
    'velocity_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity embedding
    finished (0:00:00) --> added
    'velocity_umap', embedded velocity vectors (adata.obsm)
```

Example 110 (python):
```python
adata = scv.utils.merge(processeddata, ldata)

scv.logging.print_version()
scv.settings.verbosity = 3  # show errors(0), warnings(1), info(2), hints(3)
scv.settings.presenter_view = True  # set max width size for presenter view
scv.set_figure_params('scvelo')  # for beautified visualization

###BASICS

scv.pl.proportions(adata)

scv.pp.filter_genes(adata, min_shared_counts=20)
scv.pp.normalize_per_cell(adata)
scv.pp.filter_genes_dispersion(adata, n_top_genes=len(adata.var_names))
scv.pp.log1p(adata)
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=len(adata.var_names))
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)

scv.tl.velocity(adata)
scv.tl.velocity_graph(adata)
scv.pl.velocity_embedding(adata, basis='draw_graph_fa')
scv.pl.velocity_embedding_grid(adata, basis='draw_graph_fa')
scv.pl.velocity_embedding_stream(adata, basis='draw_graph_fa')
scv.pl.velocity_embedding_stream(adata, basis='draw_graph_fa',color='fine_grain',palette=('Set2'),arrow_color='darkslategray')
scv.pl.velocity_embedding_stream(adata, basis='draw_graph_fa',color='cycling',palette=('Set2'),arrow_color='darkslategray')
scv.pl.velocity_embedding(adata, arrow_length=3, arrow_size=2, dpi=120)
```

Example 111 (unknown):
```unknown
Running scvelo 0.2.4 (python 3.8.11) on 2023-08-31 09:10.
```

Example 112 (unknown):
```unknown
ERROR: XMLRPC request failed [code: -32500]
RuntimeError: PyPI no longer supports 'pip search' (or XML-RPC search). Please use https://pypi.org/search (via a browser) instead. See https://warehouse.pypa.io/api-reference/xml-rpc.html#deprecated-methods for more information.
```

Example 113 (python):
```python
Filtered out 1183 genes that are detected 20 counts (shared).
WARNING: Did not normalize X as it looks processed already. To enforce normalization, set `enforce=True`.
Normalized count data: spliced, unspliced.
Extracted 2490 highly variable genes.
Filtered out 591 genes that are detected 20 counts (shared).
WARNING: Did not normalize X as it looks processed already. To enforce normalization, set `enforce=True`.
WARNING: Did not normalize spliced as it looks processed already. To enforce normalization, set `enforce=True`.
WARNING: Did not normalize unspliced as it looks processed already. To enforce normalization, set `enforce=True`.
Skip filtering by dispersion since number of variables are less than `n_top_genes`.
WARNING: Did not modify X as it looks preprocessed already.
computing PCA
    on highly variable genes
    with n_comps=30
    finished (0:00:00)
computing neighbors
    finished (0:00:00) --> added 
    'distances' and 'connectivities', weighted adjacency matrices (adata.obsp)
computing moments based on connectivities
    finished (0:00:00) --> added 
    'Ms' and 'Mu', moments of un/spliced abundances (adata.layers)
computing velocities
    finished (0:00:00) --> added 
    'velocity', velocity vectors for each individual cell (adata.layers)
computing velocity graph (using 1/32 cores)
```

Example 114 (unknown):
```unknown
0%|          | 0/2691 [00:00<?, ?cells/s]
```

Example 115 (python):
```python
finished (0:00:03) --> added 
    'velocity_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity embedding
    finished (0:00:00) --> added
    'velocity_draw_graph_fa', embedded velocity vectors (adata.obsm)
```

Example 116 (python):
```python
computing velocity embedding
    finished (0:00:00) --> added
    'velocity_umap', embedded velocity vectors (adata.obsm)
```

Example 117 (python):
```python
scv.pl.velocity(adata, [ 'ACTA2'], ncols=2, add_outline=True)

scv.tl.velocity_confidence(adata)
keys = 'velocity_length', 'velocity_confidence'
scv.pl.scatter(adata, c=keys, cmap='coolwarm', perc=[5, 95])
df = adata.obs.groupby('leiden')[keys].mean().T
df.style.background_gradient(cmap='coolwarm', axis=1)
scv.pl.velocity_graph(adata, threshold=.1)

x, y = scv.utils.get_cell_transitions(adata, basis='umap', starting_cell=70)
ax = scv.pl.velocity_graph(adata, c='lightgrey', edge_width=.05, show=False)
ax = scv.pl.scatter(adata, x=x, y=y, s=120, c='ascending', cmap='gnuplot', ax=ax)

scv.tl.velocity_pseudotime(adata)
scv.pl.scatter(adata, color='velocity_pseudotime', cmap='gnuplot')


adata.uns['neighbors']['distances'] = adata.obsp['distances']
adata.uns['neighbors']['connectivities'] = adata.obsp['connectivities']
scv.tl.paga(adata, groups='leiden')
df = scv.get_df(adata, 'paga/transitions_confidence', precision=2).T
df.style.background_gradient(cmap='Blues').format('{:.2g}')
scv.pl.paga(adata, basis='umap', size=50, alpha=.1, min_edge_width=2, node_size_scale=1.5)


### DYNAMICAL MODELLING
scv.tl.recover_dynamics(adata)
scv.tl.velocity(adata, mode='dynamical')
scv.tl.velocity_graph(adata)

df = adata.var
df = df[(df['fit_likelihood'] > .1) & df['velocity_genes'] == True]
kwargs = dict(xscale='log', fontsize=16)
with scv.GridSpec(ncols=3) as pl:
    pl.hist(df['fit_alpha'], xlabel='transcription rate', **kwargs)
    pl.hist(df['fit_beta'] * df['fit_scaling'], xlabel='splicing rate', xticks=[.1, .4, 1], **kwargs)
    pl.hist(df['fit_gamma'], xlabel='degradation rate', xticks=[.1, .4, 1], **kwargs)
scv.get_df(adata, 'fit*', dropna=True).head()

scv.tl.latent_time(adata)
scv.pl.scatter(adata, color='latent_time', color_map='gnuplot', size=80)
top_genes = adata.var['fit_likelihood'].sort_values(ascending=False).index[:300]
scv.pl.heatmap(adata, var_names=top_genes, sortby='latent_time', col_color='leiden', n_convolve=100)
top_genes = adata.var['fit_likelihood'].sort_values(ascending=False).index
scv.pl.scatter(adata, basis=top_genes[:15], ncols=5, frameon=False)

var_names = [ 'ACTA2', 'DCN']
scv.pl.scatter(adata, var_names, frameon=False)
scv.pl.scatter(adata, x='latent_time', y=var_names, frameon=False)

scv.tl.rank_dynamical_genes(adata, groupby='leiden')
df = scv.get_df(adata, 'rank_dynamical_genes/names')
df.head(5)

for cluster in ['0', '1', '2', '3','4']:
    scv.pl.scatter(adata, df[cluster][:10], ylabel=cluster, frameon=False)
    
var_names = [ 'ACTA2', 'MYH11']
scv.tl.differential_kinetic_test(adata, var_names=var_names, groupby='leiden')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no03_harmony.html

**Contents:**
- Read in¶
- Log-normalise¶
- PCA¶
- Run Harmony¶
- Save¶
- kNN graph, UMAP, Clustering¶
- Save¶

**Examples:**

Example 1 (python):
```python
import scanpy as sc
import numpy as np
import pandas as pd
import os
# import rapids_singlecell as rsc
from tqdm import tqdm

import matplotlib.pyplot as plt
import seaborn as sns
```

Example 2 (python):
```python
# import session_info
# session_info.show()
```

Example 3 (python):
```python
sc.settings.set_figure_params(dpi=120)
```

Example 4 (python):
```python
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
print(adata.X.data[:5])
adata
```

Example 5 (unknown):
```unknown
[5. 1. 1. 2. 2.]
```

Example 6 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    obsm: 'spatial'
```

Example 7 (python):
```python
adata_lognorm = adata.copy()
```

Example 8 (python):
```python
# filter genes
sc.pp.filter_genes(adata_lognorm, min_cells=3)
```

Example 9 (python):
```python
# log-normalise the count
sc.pp.normalize_total(adata_lognorm,target_sum=1e4)
sc.pp.log1p(adata_lognorm)
adata_lognorm.X.data[:5]
```

Example 10 (unknown):
```unknown
array([4.2093534, 2.6576407, 2.6576407, 3.3151019, 3.3151019],
      dtype=float32)
```

Example 11 (python):
```python
# Create simple reduced dimensional space using PCA
sc.tl.pca(adata_lognorm)
adata_lognorm
```

Example 12 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells'
    uns: 'log1p', 'pca'
    obsm: 'spatial', 'X_pca'
    varm: 'PCs'
```

Example 13 (python):
```python
import scanpy.external as sce
```

Example 14 (python):
```python
%%time
sce.pp.harmony_integrate(adata_lognorm, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
```

Example 15 (unknown):
```unknown
2025-05-29 11:30:02,396 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-05-29 11:30:37,959 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-05-29 11:30:39,610 - harmonypy - INFO - Iteration 1 of 10
2025-05-29 11:32:38,887 - harmonypy - INFO - Iteration 2 of 10
2025-05-29 11:34:33,817 - harmonypy - INFO - Iteration 3 of 10
2025-05-29 11:36:26,974 - harmonypy - INFO - Iteration 4 of 10
2025-05-29 11:38:20,918 - harmonypy - INFO - Iteration 5 of 10
2025-05-29 11:40:11,757 - harmonypy - INFO - Converged after 5 iterations
```

Example 16 (unknown):
```unknown
CPU times: user 33min 39s, sys: 57.2 s, total: 34min 37s
Wall time: 10min 14s
```

Example 17 (python):
```python
# add to original adata
adata.uns['pca'] = adata_lognorm.uns['pca'].copy()
adata.obsm['X_pca'] = adata_lognorm.obsm['X_pca'].copy()
adata.obsm['X_pca_harmony'] = adata_lognorm.obsm['X_pca_harmony'].copy()
adata.varm['PCs'] = adata_lognorm.varm['PCs'].copy()
adata
```

Example 18 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'pca'
    obsm: 'spatial', 'X_pca', 'X_pca_harmony'
    varm: 'PCs'
```

Example 19 (python):
```python
adata.write(path_adata)
adata
```

Example 20 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'pca'
    obsm: 'spatial', 'X_pca', 'X_pca_harmony'
    varm: 'PCs'
```

Example 21 (python):
```python
key_added = 'pca_harmony'
print("making kNN graph...")
sc.pp.neighbors(adata,use_rep=f"X_{key_added}",key_added=key_added)
print("computing UMAP coordinates...")
sc.tl.umap(adata, min_dist=0.2, neighbors_key=key_added)
adata.obsm[f"X_umap_{key_added}"]=adata.obsm["X_umap"] # rename the generic X_umap coordinates
del adata.obsm["X_umap"]
```

Example 22 (unknown):
```unknown
making kNN graph...
```

Example 23 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 24 (unknown):
```unknown
computing UMAP coordinates...
```

Example 25 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{key_added}",
                color=['total_counts','tissue_block_id'], wspace=0.2, cmap='RdPu')
```

Example 26 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{key_added}",
                color=['celltypist_mid_fin'], wspace=0.2, cmap='RdPu')
```

Example 27 (python):
```python
adata.write(path_adata)
adata
```

Example 28 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'pca', 'pca_harmony', 'umap', 'tissue_block_id_colors', 'celltypist_mid_fin_colors'
    obsm: 'spatial', 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony'
    varm: 'PCs'
    obsp: 'pca_harmony_distances', 'pca_harmony_connectivities'
```

Example 29 (unknown):
```unknown
/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/Xenium/5K/C194_Hst45/CamU
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_PericardialCells.html

**Contents:**
- Variables¶
- Read in data¶
- Markers¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 0 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-12 17:55
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'PericardialCells'
```

Example 10 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 8698 × 4737
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([2.9218001, 2.9218001, 2.9218001, 3.58766  , 2.9218001],
      dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 5.86 s, sys: 110 ms, total: 5.97 s
Wall time: 5.98 s
```

Example 21 (python):
```python
# read in markers identified using single-nucleus data
markers_df = pd.read_csv(f'/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_{celltype}_finegrain_markers.csv')

mask1 = markers_df['group_mean']>1
mask2 = markers_df['logfoldchanges']>1
markers_df = markers_df[mask1&mask2]

markers_df
```

Example 22 (python):
```python
markers = {}
n_top = 50
for c in set(markers_df['group']):
    markers_df_sub = markers_df[markers_df['group']==c]
    markers_df_sub.sort_values('logfoldchanges',ascending=False)
    markers[c]=list(markers_df_sub[:n_top]['names'])

# manually add genes
markers['Cycling'] = ['MKI67','TOP2A'] 

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in list(adata.var_names))&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in list(adata.var_names)]
len(genes)
```

Example 23 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",color=genes, size=20,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 24 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",
                color=['celltypist_midmod2fine', 'conf_score_midmod2fine'],
                wspace=0.7)
```

Example 25 (python):
```python
# umap per celltype to highlight
group_col = 'celltypist_midmod2fine'
groups_to_plot = list(set(adata.obs[group_col]))

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,7))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",
                    color=[group_col], groups=grp, 
               size=30, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 26 (unknown):
```unknown
resolution_sel = 0.6
```

Example 27 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              markers_others, 
              groupby=f'leiden_{str(resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 28 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 29 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 30 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: PericardialCellsParietal, PericardialCellsIntermediate, PericardialCellsFibrous, etc.
```

Example 31 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 32 (unknown):
```unknown
[2.9218001 2.9218001 2.9218001 3.58766   2.9218001]
```

Example 33 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 34 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 35 (unknown):
```unknown
'PericardialCells'
```

Example 36 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'unassigned',
    '1':'PericardialCells',
    '2':'PericardialCells',
    '3':'PericardialCells',
    '4':'PericardialCells',
    '5':'?ThyroidCells',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 37 (python):
```python
/tmp/ipykernel_419353/351917040.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 38 (unknown):
```unknown
tmp_annotation
PericardialCells    5374
unassigned          3266
?ThyroidCells         58
Name: count, dtype: int64
```

Example 39 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 40 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['PericardialCells'])]
```

Example 41 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 42 (unknown):
```unknown
AnnData object with n_obs × n_vars = 5374 × 4737
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.6', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 43 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 44 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 5374 × 4280
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.6', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 45 (python):
```python
'''
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
'''
```

Example 46 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 47 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 48 (unknown):
```unknown
number of hvgs: 825
```

Example 49 (python):
```python
2025-06-12 18:00:09,972 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-12 18:00:11,635 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-12 18:00:11,737 - harmonypy - INFO - Iteration 1 of 10
2025-06-12 18:00:12,403 - harmonypy - INFO - Iteration 2 of 10
2025-06-12 18:00:13,065 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 50 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 51 (unknown):
```unknown
CPU times: user 7.26 s, sys: 106 ms, total: 7.37 s
Wall time: 7.38 s
```

Example 52 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",size=10,
                color=genes,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 53 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=["conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 54 (python):
```python
# umap per celltype to highlight
group_col = 'celltypist_midmod2fine'
groups_to_plot = list(set(adata_sub.obs[group_col]))

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,8))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                    color=[group_col], groups=grp, 
               size=20, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 55 (unknown):
```unknown
sub_resolution_sel = 0.6
```

Example 56 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              markers_others, 
              groupby=f'leiden_{str(sub_resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 57 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 58 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 59 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: PericardialCellsParietal, PericardialCellsIntermediate, PericardialCellsFibrous, etc.
```

Example 60 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 61 (unknown):
```unknown
[2.7834363 2.7834363 2.7834363 2.7834363 2.7834363]
```

Example 62 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 63 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'PericardialCellsFibrous',
    '1':'PericardialCellsFibrous',
    '2':'PericardialCellsIntermediate',
    '3':'PericardialCellsCycling',
    '4':'PericardialCellsIntermediate',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 64 (python):
```python
/tmp/ipykernel_419353/2716599662.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 65 (unknown):
```unknown
fine_grain_manual
PericardialCellsFibrous         3017
PericardialCellsIntermediate    1553
PericardialCellsCycling          804
Name: count, dtype: int64
```

Example 66 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 67 (python):
```python
sc.tl.dendrogram(adata_sub,groupby='fine_grain_manual')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 68 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: PericardialCellsFibrous, PericardialCellsIntermediate, PericardialCellsCycling
var_group_labels: PericardialCellsParietal, PericardialCellsIntermediate, PericardialCellsFibrous, etc.
```

Example 69 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 70 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 71 (python):
```python
sc.tl.dendrogram(adata,groupby='fine_grain_manual')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 72 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: ?ThyroidCells, PericardialCellsCycling, PericardialCellsFibrous, etc.
var_group_labels: PericardialCellsParietal, PericardialCellsIntermediate, PericardialCellsFibrous, etc.
```

Example 73 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=60,vmax='p100')
```

Example 74 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 75 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 76 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 77 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 78 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 79 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 80 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 81 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 82 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 83 (python):
```python
/tmp/ipykernel_419353/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 84 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 85 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_PericardialCells_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig5_Trisomy21/no02_t21_post-scVI_cleanup_and_celltypist.html

**Contents:**
- Import modules¶
- Read in data¶
- Filter and log-normalise¶
- CellTypist prediction¶
- Select cells to remove¶
- Remove from the raw data¶
- recalculate UMAP, etc¶
- Modify obs¶
- CellTypist prediction for fine-grained labels (run per coarse-grained)¶

"Pericardium" region is not represented in "Heart" and other region samples. In addition, "Pericardium" sample is coming from one donor "Pericardium" sample will be in the dataset but will be removed at downstream analysis (e.g. Milo)

**Examples:**

Example 1 (python):
```python
import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import matplotlib.pyplot as plt
import seaborn as sns
import celltypist
```

Example 2 (python):
```python
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 3 (python):
```python
import session_info
session_info.show()
```

Example 4 (python):
```python
-----
celltypist          1.6.2
matplotlib          3.7.2
numpy               1.22.4
pandas              1.5.3
scanpy              1.9.3
seaborn             0.12.2
session_info        1.0.0
-----
```

Example 5 (python):
```python
PIL                         10.0.0
anndata                     0.9.2
anyio                       NA
arrow                       1.2.3
asciitree                   NA
asttokens                   NA
attr                        23.1.0
attrs                       23.1.0
babel                       2.12.1
backcall                    0.2.0
brotli                      1.0.9
certifi                     2023.11.17
cffi                        1.15.1
charset_normalizer          3.2.0
cloudpickle                 3.0.0
colorama                    0.4.6
comm                        0.1.4
cycler                      0.10.0
cython_runtime              NA
dask                        2023.5.0
dateutil                    2.8.2
debugpy                     1.6.8
decorator                   5.1.1
defusedxml                  0.7.1
executing                   1.2.0
fasteners                   0.19
fastjsonschema              NA
fqdn                        NA
h5py                        3.9.0
idna                        3.4
igraph                      0.10.6
importlib_metadata          NA
importlib_resources         NA
ipykernel                   6.25.1
isoduration                 NA
jedi                        0.19.0
jinja2                      3.1.2
joblib                      1.3.2
json5                       NA
jsonpointer                 2.0
jsonschema                  4.19.0
jsonschema_specifications   NA
jupyter_events              0.7.0
jupyter_server              2.7.1
jupyterlab_server           2.24.0
kiwisolver                  1.4.5
leidenalg                   0.10.1
llvmlite                    0.38.1
markupsafe                  2.1.3
mpl_toolkits                NA
natsort                     8.4.0
nbformat                    5.9.2
numba                       0.55.2
numcodecs                   0.12.1
opt_einsum                  v3.3.0
overrides                   NA
packaging                   23.1
parso                       0.8.3
patsy                       0.5.3
pexpect                     4.8.0
pickleshare                 0.7.5
pkg_resources               NA
plotly                      5.16.1
prometheus_client           NA
prompt_toolkit              3.0.39
psutil                      5.9.5
ptyprocess                  0.7.0
pure_eval                   0.2.2
pyarrow                     15.0.2
pydev_ipython               NA
pydevconsole                NA
pydevd                      2.9.5
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pygments                    2.16.1
pyparsing                   3.0.9
pythonjsonlogger            NA
pytz                        2023.3
referencing                 NA
requests                    2.31.0
rfc3339_validator           0.1.4
rfc3986_validator           0.1.1
rpds                        NA
ruamel                      NA
scipy                       1.10.1
send2trash                  NA
six                         1.16.0
sklearn                     1.3.0
sniffio                     1.3.0
socks                       1.7.1
sphinxcontrib               NA
stack_data                  0.6.2
statsmodels                 0.14.0
texttable                   1.6.7
threadpoolctl               3.2.0
tlz                         0.12.1
toolz                       0.12.1
torch                       1.13.1+cu117
tornado                     6.3.3
tqdm                        4.66.1
traitlets                   5.9.0
typing_extensions           NA
uri_template                NA
urllib3                     2.0.4
wcwidth                     0.2.6
webcolors                   1.13
websocket                   1.6.2
yaml                        6.0.1
zarr                        2.16.1
zipp                        NA
zmq                         25.1.1
zstandard                   0.19.0
```

Example 6 (unknown):
```unknown
-----
IPython             8.12.0
jupyter_client      8.3.0
jupyter_core        4.12.0
jupyterlab          4.0.5
notebook            7.0.2
-----
Python 3.8.17 (default, Jul  5 2023, 21:04:15) [GCC 11.2.0]
Linux-5.15.0-113-generic-x86_64-with-glibc2.17
-----
Session information updated at 2024-08-01 08:21
```

Example 7 (python):
```python
# import own function
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/nfs/team205/kk18/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=120)
```

Example 9 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_July2024.h5ad')
adata
```

Example 10 (unknown):
```unknown
AnnData object with n_obs × n_vars = 121452 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1'
    var: 'gene_name', 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts'
    uns: 'age_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 11 (python):
```python
adata.var['gene_id'] = adata.var_names.copy()
adata.var.set_index('gene_name',inplace=True)
adata.var_names = adata.var_names.astype('str')
adata.var_names_make_unique()
```

Example 12 (python):
```python
sc.pp.filter_genes(adata, min_cells=3)
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
```

Example 13 (unknown):
```unknown
filtered out 3535 genes that are detected in less than 3 cells
normalizing counts per cell
    finished (0:00:01)
```

Example 14 (python):
```python
print(adata.shape)
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
(121452, 33066)
```

Example 16 (unknown):
```unknown
array([0.0534004 , 0.10409318, 0.19836526, 0.0534004 , 0.15233971],
      dtype=float32)
```

Example 17 (python):
```python
# coarse-grained
predictions = celltypist.annotate(adata, 
                                  model = '/nfs/team205/kk18/notebooks/Foetal/VisiumHD/mpp0p3/celltypist_models/from_foetal_portal/foetal_heart_coarse.pkl', 
                                  majority_voting = False)

# add to anndata
adata = predictions.to_adata(insert_labels = True, insert_conf = True)
adata.obs.rename(columns={'predicted_labels':'celltypist_coarse',
                              'conf_score':'conf_score_coarse'
                             },inplace=True)
adata.obs.head()
```

Example 18 (unknown):
```unknown
🔬 Input data has 121452 cells and 33066 genes
🔗 Matching reference genes in the model
🧬 29480 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
```

Example 19 (python):
```python
sc.pl.umap(adata, color=['celltypist_coarse','conf_score_coarse','leiden_scVI_1'], size=1, legend_fontsize=6, wspace=0.2)
```

Example 20 (python):
```python
# umap per celltype to highlight
group_col = 'region'
groups_to_plot = ['Heart',
                  'Great vessels', 
                 'Left atria',
                 'Left ventricle',
                 'Pericardial sac + RA + LA + IAS',
                 'Right ventricle',
                  'Pericardium',
                 ]

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,7))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.umap(adata, color=[group_col], groups=grp, 
               size=10, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 21 (python):
```python
# mean condidence score
group_col = 'leiden_scVI_1'
conf_score_col = 'conf_score_coarse'
df = adata.obs[[group_col,conf_score_col]].groupby(group_col).mean()
df.sort_values(conf_score_col,ascending=False)
```

Example 22 (python):
```python
# cell type marker expression
markers = {
    'vCM': ['MYH7', 'MYL2', 'FHL2'],
    'aCM': ['NPPA', 'MYL7', 'MYL4'],
    'FB': ['DCN', 'GCN', 'PDGFRA'],
    'EC': ['VWF', 'PECAM1', 'CDH5'],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=group_col)
sc.pl.dotplot(adata,
              markers, 
              groupby=group_col,
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 23 (unknown):
```unknown
using 'X_pca' with n_pcs = 50
Storing dendrogram info using `.uns['dendrogram_leiden_scVI_1']`
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: vCM, aCM, FB, etc.
```

Example 24 (python):
```python
# sangerID proportion
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["region"])
# Normalize each row to sum to 1 (i.e., to get fractions)
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)

# Plotting the stacked bar chart
ax = crosstab_normalized.plot(kind='bar',stacked=True,figsize=(10, 4),legend=False)

# Adding labels and title
plt.ylabel('Fraction')
plt.title('Normalized Stacked Bar Chart')
plt.legend(bbox_to_anchor=(0.95, 0.5, 0.5, 0.5))

# Show the plot
plt.show()
```

Example 25 (python):
```python
# donor proportion
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["donor"])
# Normalize each row to sum to 1 (i.e., to get fractions)
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)

# Plotting the stacked bar chart
ax = crosstab_normalized.plot(kind='bar',stacked=True,figsize=(10, 4),legend=False)

# Adding labels and title
plt.ylabel('Fraction')
plt.title('Normalized Stacked Bar Chart')
plt.legend(bbox_to_anchor=(0.8, 0., 0.5, 0.5))

# Show the plot
plt.show()
```

Example 26 (python):
```python
# sangerID proportion
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["sangerID"])
# Normalize each row to sum to 1 (i.e., to get fractions)
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)

# Plotting the stacked bar chart
ax = crosstab_normalized.plot(kind='bar',stacked=True,figsize=(10, 4),legend=False)

# Adding labels and title
plt.ylabel('Fraction')
plt.title('Normalized Stacked Bar Chart')
plt.legend(bbox_to_anchor=(0.8, 0.5, 0.5, 0.5))

# Show the plot
plt.show()
```

Example 27 (python):
```python
sc.settings.set_figure_params(dpi=120)
sc.pl.umap(adata, color=['leiden_scVI_1'], size=1, legend_fontsize=6, wspace=0.2, legend_loc='on data')
```

Example 28 (python):
```python
conf_score_thresh = 0.6

# identify single-sample clusters
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["sangerID"])
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)
res = crosstab_normalized.max(axis=1)
single_sample_clusters = list(res.index[res>0.9])
print(f'single_sample_clusters: {single_sample_clusters}')

# identify pericardium clusters
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["region"])
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)
res = crosstab_normalized['Pericardium']
pericardium_clusters = list(res.index[res>0.9])
print(f'pericardium_clusters: {pericardium_clusters}')

single_butnot_peri_clusters = list(set(single_sample_clusters)-set(pericardium_clusters))
print(f'single_butnot_peri_clusters: {single_butnot_peri_clusters}')

mask1 = adata.obs[group_col].isin(['4','19'])
mask2 = adata.obs[conf_score_col] < conf_score_thresh
mask3 = adata.obs[group_col].isin(single_butnot_peri_clusters)
adata.obs['cells_to_remove'] = 'No'
adata.obs.loc[adata.obs_names[mask1|mask2|mask3],'cells_to_remove'] = 'Yes'
sc.pl.umap(adata, color=['cells_to_remove'], size=1, legend_fontsize=6, wspace=0.2)
```

Example 29 (unknown):
```unknown
... storing 'cells_to_remove' as categorical
```

Example 30 (unknown):
```unknown
single_sample_clusters: ['4', '12', '14', '17', '19', '21', '27', '30', '36']
pericardium_clusters: ['12', '14', '17', '19', '21', '27', '30']
single_butnot_peri_clusters: ['36', '4']
```

Example 31 (python):
```python
adata_raw = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_July2024.h5ad')
adata_raw
```

Example 32 (unknown):
```unknown
AnnData object with n_obs × n_vars = 121452 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1'
    var: 'gene_name', 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts'
    uns: 'age_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 33 (python):
```python
adata_raw.var['gene_id'] = adata_raw.var_names.copy()
adata_raw.var.set_index('gene_name',inplace=True)
adata_raw.var_names = adata_raw.var_names.astype('str')
adata_raw.var_names_make_unique()
```

Example 34 (python):
```python
# add prediction results, etc
adata_raw.obs[['celltypist_coarse','conf_score_coarse','cells_to_remove']] = adata[adata_raw.obs_names].obs[['celltypist_coarse','conf_score_coarse','cells_to_remove']].copy()
```

Example 35 (python):
```python
# remove
adata_raw = adata_raw[adata_raw.obs['cells_to_remove']=='No']
sc.pl.umap(adata_raw, color=['cells_to_remove'], size=1, legend_fontsize=6, wspace=0.2)
```

Example 36 (python):
```python
# save
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
```

Example 37 (python):
```python
%%time
sc.pp.neighbors(adata_raw, use_rep="X_scVI")
sc.tl.umap(adata_raw, min_dist=0.2)
```

Example 38 (python):
```python
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:37)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:02:11)
CPU times: user 2min 46s, sys: 733 ms, total: 2min 47s
Wall time: 2min 49s
```

Example 39 (python):
```python
sc.pl.umap(adata_raw, color=['celltypist_coarse'], frameon=False)
```

Example 40 (python):
```python
sc.pl.umap(adata_raw, color=['donor'], frameon=False)
```

Example 41 (python):
```python
# save
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
```

Example 42 (python):
```python
# age
adata_raw.obs.replace({'age':{
    'PCW-11w':'11W0D',
    'PCW-13w':'13W0D',
    'PCW-14w':'14W0D',
}},inplace=True)

adata_raw.obs['week'] = [x.split('0D')[0] for x in adata_raw.obs['age']]
adata_raw.obs['trimester'] = adata_raw.obs['age'].astype('str').copy()
adata_raw.obs.replace({'trimester':{
    '11W0D':'firsttrimester',
    '13W0D':'secondtrimester',
    '14W0D':'secondtrimester',
}},inplace=True)
```

Example 43 (python):
```python
adata_raw.obs.drop(['gender'],axis=1,inplace=True)
```

Example 44 (python):
```python
# sex
adata_raw.obs['sex'] = adata_raw.obs['donor'].astype('str').copy()
adata_raw.obs.replace({'sex':{
    'Hst32':'female',
    'Hst42':'male',
    'Hst44':'male',
    'Hst48':'male'
}},inplace=True)
```

Example 45 (python):
```python
# save
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
adata_raw
```

Example 46 (unknown):
```unknown
... storing 'week' as categorical
... storing 'trimester' as categorical
... storing 'sex' as categorical
```

Example 47 (unknown):
```unknown
AnnData object with n_obs × n_vars = 110693 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'week', 'trimester', 'sex'
    var: 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'gene_id'
    uns: 'age_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap', 'cells_to_remove_colors', 'celltypist_coarse_colors'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 48 (python):
```python
adata_raw = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
adata_raw
```

Example 49 (unknown):
```unknown
AnnData object with n_obs × n_vars = 110693 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'week', 'trimester', 'sex', 'celltypist_fine', 'conf_score_fine'
    var: 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'gene_id'
    uns: 'age_colors', 'cells_to_remove_colors', 'celltypist_coarse_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 50 (python):
```python
adata = adata_raw.copy()
sc.pp.filter_genes(adata, min_cells=3)
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
adata.X.data[:5]
```

Example 51 (unknown):
```unknown
filtered out 3663 genes that are detected in less than 3 cells
normalizing counts per cell
    finished (0:00:00)
```

Example 52 (unknown):
```unknown
array([0.0534004 , 0.10409318, 0.19836526, 0.0534004 , 0.15233971],
      dtype=float32)
```

Example 53 (python):
```python
adata.obs['celltypist_coarse'].value_counts()
```

Example 54 (unknown):
```unknown
Mesenchymal       49009
Cardiomyocytes    42792
Endothelium        8089
Leukocytes         7262
Epicardium         2071
Neural             1470
Name: celltypist_coarse, dtype: int64
```

Example 55 (python):
```python
# predict per coarse_grained cell type
for celltype in adata.obs['celltypist_coarse'].unique():
    print(celltype)
    # subset adata
    adata_sub = adata[adata.obs['celltypist_coarse']==celltype]
    # drop all the obs columns
    adata_sub.obs.drop(columns=adata_sub.obs.columns,inplace=True)
    # predict
    predictions = celltypist.annotate(adata_sub, 
                                      model = f'/nfs/team205/kk18/notebooks/Foetal/Trisomy21/celltypist_models/coarse2fine_{celltype}.pkl', 
                                      majority_voting = False)

    # add to subsetted anndata
    adata_sub = predictions.to_adata(insert_labels = True, insert_conf = True)
    adata_sub.obs.rename(columns={'predicted_labels':'celltypist_fine',
                                  'conf_score':'conf_score_fine'
                                 },inplace=True)
    # add to the original anndata
    adata.obs.loc[adata_sub.obs_names,'celltypist_fine'] = list(adata_sub.obs['celltypist_fine'])
    adata.obs.loc[adata_sub.obs_names,'conf_score_fine'] = list(adata_sub.obs['conf_score_fine'])
```

Example 56 (unknown):
```unknown
Mesenchymal
```

Example 57 (unknown):
```unknown
🔬 Input data has 49009 cells and 32938 genes
🔗 Matching reference genes in the model
🧬 32502 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
🔬 Input data has 8089 cells and 32938 genes
🔗 Matching reference genes in the model
```

Example 58 (unknown):
```unknown
Endothelium
```

Example 59 (unknown):
```unknown
🧬 31696 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
🔬 Input data has 2071 cells and 32938 genes
🔗 Matching reference genes in the model
```

Example 60 (unknown):
```unknown
🧬 30529 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
```

Example 61 (unknown):
```unknown
Cardiomyocytes
```

Example 62 (unknown):
```unknown
🔬 Input data has 42792 cells and 32938 genes
🔗 Matching reference genes in the model
🧬 31533 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
🔬 Input data has 1470 cells and 32938 genes
🔗 Matching reference genes in the model
```

Example 63 (unknown):
```unknown
🧬 29361 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
🔬 Input data has 7262 cells and 32938 genes
🔗 Matching reference genes in the model
```

Example 64 (unknown):
```unknown
🧬 31793 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
```

Example 65 (python):
```python
# add prediction results
adata_raw.obs[['celltypist_fine','conf_score_fine']] = adata[adata_raw.obs_names].obs[['celltypist_fine','conf_score_fine']].copy()
```

Example 66 (python):
```python
sc.pl.umap(adata_raw, color=['conf_score_fine','celltypist_fine'], frameon=False)
```

Example 67 (python):
```python
sc.pl.umap(adata_raw, color=['celltypist_coarse'], frameon=False)
```

Example 68 (python):
```python
# save
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
adata_raw
```

Example 69 (unknown):
```unknown
AnnData object with n_obs × n_vars = 110693 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'week', 'trimester', 'sex', 'celltypist_fine', 'conf_score_fine'
    var: 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'gene_id'
    uns: 'age_colors', 'cells_to_remove_colors', 'celltypist_coarse_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap', 'celltypist_fine_colors'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 70 (python):
```python
# save .obs for later use
adata_raw.obs.to_csv('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.obs.csv')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Leukocytes/ImmuneDE.html

**Contents:**
- Subcluster¶

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-09-01 22:07.
```

Example 5 (python):
```python
sc.settings.set_figure_params(dpi=300, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
```

Example 6 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 7 (unknown):
```unknown
(297473, 36601)
```

Example 8 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 9 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 10 (python):
```python
#Expression: "YlGn" (e.g. DE plots)
#Divergent expression: "PRGn" (e.g. log2FC)
#Age: "afmhot_r"
#Others: "viridis" (e.g. UMAP expression)

#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodePacemakerCells':'#854834',
    'AtrioventricularNodePacemakerCells':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 11 (python):
```python
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_61971/621898565.py in <module>
     70     'InnateLymphoidCells':'#72497f',
     71 }
---> 72 sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)
     73 
     74 MidGrainPalette={

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in umap(adata, **kwargs)
    657     tl.umap
    658     """
--> 659     return embedding(adata, 'umap', **kwargs)
    660 
    661 

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in embedding(adata, basis, color, gene_symbols, use_raw, sort_order, edges, edges_width, edges_color, neighbors_key, arrows, arrows_kwds, groups, components, layer, projection, scale_factor, color_map, cmap, palette, na_color, na_in_legend, size, frameon, legend_fontsize, legend_fontweight, legend_loc, legend_fontoutline, vmax, vmin, vcenter, norm, add_outline, outline_width, outline_color, ncols, hspace, wspace, title, show, save, ax, return_fig, **kwargs)
    250             groups=groups,
    251         )
--> 252         color_vector, categorical = _color_vector(
    253             adata,
    254             value_to_plot,

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in _color_vector(adata, values_key, values, palette, na_color)
   1267         color_map = {
   1268             k: to_hex(v)
-> 1269             for k, v in _get_palette(adata, values_key, palette=palette).items()
   1270         }
   1271         # If color_map does not have unique values, this can be slow as the

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in _get_palette(adata, values_key, palette)
   1233     values = pd.Categorical(adata.obs[values_key])
   1234     if palette:
-> 1235         _utils._set_colors_for_categorical_obs(adata, values_key, palette)
   1236     elif color_key not in adata.uns or len(adata.uns[color_key]) < len(
   1237         values.categories

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_utils.py in _set_colors_for_categorical_obs(adata, value_to_plot, palette)
    388         colors_list = [to_hex(x) for x in cmap(np.linspace(0, 1, len(categories)))]
    389     elif isinstance(palette, cabc.Mapping):
--> 390         colors_list = [to_hex(palette[k], keep_alpha=True) for k in categories]
    391     else:
    392         # check if palette is a list and convert it to a cycler, thus

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_utils.py in <listcomp>(.0)
    388         colors_list = [to_hex(x) for x in cmap(np.linspace(0, 1, len(categories)))]
    389     elif isinstance(palette, cabc.Mapping):
--> 390         colors_list = [to_hex(palette[k], keep_alpha=True) for k in categories]
    391     else:
    392         # check if palette is a list and convert it to a cycler, thus

KeyError: 'ParasympatheticNeurons'
```

Example 12 (python):
```python
set(adata.obs.fine_grain)
```

Example 13 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 14 (python):
```python
set(adata.obs.mid_grain)
```

Example 15 (unknown):
```unknown
{'AtrialCardiomyocytes',
 'BloodVesselEndothelialCells',
 'CardiacConductionSystem',
 'EndocardialCells',
 'EpicardialCells',
 'Fibroblasts',
 'Glia',
 'LymphaticEndothelialCells',
 'LymphoidCells',
 'MuralCells',
 'MyeloidCells',
 'Neurons',
 'PericardialCells',
 'VentricularCardiomyocytes'}
```

Example 16 (python):
```python
set(adata.obs.coarse_grain)
```

Example 17 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Leukocytes',
 'Mesenchymal',
 'Neural'}
```

Example 18 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['Myofibroblasts','CoronaryVesselAdventitialFibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts'])].copy()
#adata = adata[adata.obs['mid_grain'].isin(['PericardialCells'])].copy()
adata=adata[adata.obs.coarse_grain=='Leukocytes',:].copy()
```

Example 19 (unknown):
```unknown
AnnData object with n_obs × n_vars = 41046 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 20 (python):
```python
set(adata.obs.fine_grain)
```

Example 21 (unknown):
```unknown
{'CoronaryVesselAdventitialFibroblasts',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'SubEpicardialFibroblasts'}
```

Example 22 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 23 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:09)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1745
```

Example 24 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    121 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['BIRC5', 'NDC80', 'CKS2', 'TMPO', 'TACC3', 'CKAP2L', 'AURKB', 'ANP32E', 'KIF20B', 'HJURP', 'CDCA3', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'AURKA', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    532 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 25 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 26 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [03:01<00:00,  3.63s/it, loss=625, v_num=1]
```

Example 27 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'ZFP36', 'CEBPD', 'CEBPB', 'HSP90AB1', 'HSPA8', 'HSPE1', 'IER2', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    340 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBZ', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    293 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:04)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:12)
```

Example 28 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 29 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 30 (python):
```python
for k in list(set(adata.obs.region)):
    sc.pl.umap(adata, color='region',groups=k,palette=['red','blue'])
```

Example 31 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 32 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 33 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 34 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 35 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 36 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 37 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 38 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 39 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 40 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 41 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 42 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 43 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 44 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 45 (unknown):
```unknown
WARNING: Length of palette colors is smaller than the number of categories (palette length: 2, categories length: 15. Some categories will have the same color.
```

Example 46 (python):
```python
sc.pl.umap(adata, color='fine_grain')
sc.pl.umap(adata, color='mid_grain')
```

Example 47 (python):
```python
sc.pl.umap(adata, color='mid_grain')
```

Example 48 (python):
```python
set(adata.obs.mid_grain)
```

Example 49 (unknown):
```unknown
{'LymphoidCells', 'MyeloidCells'}
```

Example 50 (python):
```python
set(adata.obs.coarse_grain)
```

Example 51 (python):
```python
ClusterOfInterest='InnateLymphoidCells'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
CategoriesOrder=['MonocytesMPOpos','Monocytes','MonocyteDerivedCells','MacrophagesCX3CR1pos','MacrophagesTIMD4pos','MacrophagesLYVE1pos','MacrophagesATF3pos','DendriticCellsType1','DendriticCellsMature','PlasmacytoidDendriticCells','MastCells','Megakaryocytes','TCellsCD4pos','TCellsCD8pos','TregsCD4pos','ProBCells','BCells','BCellsMS4A1pos','NaturalKillerCells','InnateLymphoidCells']
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',categories_order=CategoriesOrder,standard_scale='var',cmap='PRGn')
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][50:100]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',categories_order=CategoriesOrder,standard_scale='var',cmap='PRGn')
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][100:150]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',categories_order=CategoriesOrder,standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 52 (python):
```python
Genes=['FCN1','S100A8','S100A12','PADI4','CDA','RNASE2','MPO','RBP7','SERPINA1','CLEC10A','GPAT3','CD1C','CCR2','C3','CX3CR1','HTRA1','BHLHE41','OLFML3','IGSF21','KCNMA1','IL18','ANTXR1','ESRRG','CMKLR1','SAMD4A','MMP9','SMIM35','MYO5B','ATRNL1','F13A1','LYVE1','SELENOP','FOLR2','LILRB5','ACSL1','NR4A2','ATF3','NR4A3','CXCL8','CLNK','CADM1','CLEC9A','SLC24A4','NEGR1','ENPP1','RAB7B','ANPEP','ST18','LAMP3','ENOX1','GPC5','ADAM12','ST8SIA1','XKR4','GALNT17','EFNA5','ZFPM2','ABTB2','RUNX2','ZFAT','EPHB1','CUX2','PTPRS','CLEC4C','PHEX','CPA3','HDC','GATA2','VWA5A','IL1RL1','TPSB2','TPSAB1','MS4A2','CDK15','LIF','ADCYAP1','IL5RA','MLPH','ITGA2B','GP1BB','GATA1','ITGB3','GP9','MPIG6B','CLEC1B','BCL11B','THEMIS','TCF7','LRRN3','CD6','TRAC','TAFA1','TENM1','NELL2','CD8A','CD8B','IL2RA','CTLA4','TIGIT','FOXP3','MME','VPREB1','IGLL1','DNTT','RAG1','RAG2','SH2D4B','LCN6','PCDH9','ACSM3','ADAM23','BEST3','TCL1A','MS4A1','OSBPL10','COL19A1','CD22','FCRL2','FCRL5','KLRK1','TGFBR3','GZMA','KLRD1','IL2RB','CCL5','IL18RAP','KLRC2','TOX2','RORC','AQP3','IL1R1','HPN']
CategoriesOrder=['MonocytesMPOpos','Monocytes','MonocyteDerivedCells','MacrophagesCX3CR1pos','MacrophagesTIMD4pos','MacrophagesLYVE1pos','MacrophagesATF3pos','DendriticCellsType1','DendriticCellsMature','PlasmacytoidDendriticCells','MastCells','Megakaryocytes','TCellsCD4pos','TCellsCD8pos','TregsCD4pos','ProBCells','BCells','BCellsMS4A1pos','NaturalKillerCells','InnateLymphoidCells']
sc.pl.dotplot(adata, Genes ,groupby='fine_grain',categories_order=CategoriesOrder,cmap='YlGn',standard_scale='var',var_group_positions=[(0,84),(85,131)], var_group_labels=['myeloid cells',' lymphoid cells'],var_group_rotation=0)
```

Example 53 (python):
```python
Genes=['FCN1','S100A8','S100A12','PADI4','CDA','RNASE2','MPO','RBP7','SERPINA1','CLEC10A','GPAT3','CD1C','CCR2','C3','CX3CR1','HTRA1','BHLHE41','OLFML3','IGSF21','KCNMA1','IL18','ANTXR1','ESRRG','CMKLR1','SAMD4A','MMP9','SMIM35','MYO5B','ATRNL1','F13A1','LYVE1','SELENOP','FOLR2','LILRB5','ACSL1','NR4A2','ATF3','NR4A3','CXCL8','CLNK','CADM1','CLEC9A','SLC24A4','NEGR1','ENPP1','RAB7B','ANPEP','ST18','LAMP3','ENOX1','GPC5','ADAM12','ST8SIA1','XKR4','GALNT17','EFNA5','ZFPM2','ABTB2','RUNX2','ZFAT','EPHB1','CUX2','PTPRS','CLEC4C','PHEX','CPA3','HDC','GATA2','VWA5A','IL1RL1','TPSB2','TPSAB1','MS4A2','CDK15','LIF','ADCYAP1','IL5RA','MLPH','ITGA2B','GP1BB','GATA1','ITGB3','GP9','MPIG6B','CLEC1B']
CategoriesOrder=['MonocytesMPOpos','Monocytes','MonocyteDerivedCells','MacrophagesCX3CR1pos','MacrophagesTIMD4pos','MacrophagesLYVE1pos','MacrophagesATF3pos','DendriticCellsType1','DendriticCellsMature','PlasmacytoidDendriticCells','MastCells','Megakaryocytes','TCellsCD4pos','TCellsCD8pos','TregsCD4pos','ProBCells','BCells','BCellsMS4A1pos','NaturalKillerCells','InnateLymphoidCells']
sc.pl.dotplot(adata, Genes ,groupby='fine_grain',categories_order=CategoriesOrder,cmap='YlGn',standard_scale='var',var_group_positions=[(0,84)], var_group_labels=['myeloid cells'],var_group_rotation=0)
```

Example 54 (python):
```python
Genes=['BCL11B','THEMIS','TCF7','CD6','TRAC','LRRN3','TAFA1','TENM1','NELL2','CD8A','CD8B','IL2RA','CTLA4','TIGIT','FOXP3','MME','VPREB1','IGLL1','DNTT','RAG1','RAG2','SH2D4B','LCN6','PCDH9','ACSM3','ADAM23','BEST3','TCL1A','MS4A1','OSBPL10','COL19A1','CD22','FCRL2','FCRL5','KLRK1','TGFBR3','GZMA','KLRD1','IL2RB','CCL5','IL18RAP','KLRC2','TOX2','RORC','AQP3','IL1R1','HPN']
CategoriesOrder=['MonocytesMPOpos','Monocytes','MonocyteDerivedCells','MacrophagesCX3CR1pos','MacrophagesTIMD4pos','MacrophagesLYVE1pos','MacrophagesATF3pos','DendriticCellsType1','DendriticCellsMature','PlasmacytoidDendriticCells','MastCells','Megakaryocytes','TCellsCD4pos','TCellsCD8pos','TregsCD4pos','ProBCells','BCells','BCellsMS4A1pos','NaturalKillerCells','InnateLymphoidCells']
sc.pl.dotplot(adata, Genes ,groupby='fine_grain',categories_order=CategoriesOrder,cmap='YlGn',standard_scale='var',var_group_positions=[(0,46)], var_group_labels=[' lymphoid cells'],var_group_rotation=0)
```

Example 55 (python):
```python
sc.tl.rank_genes_groups(adata, 'fine_grain', groups=['MonocytesMPOpos'], reference='Monocytes', method='t-test')
sc.pl.rank_genes_groups(adata, groups=['MonocytesMPOpos'], n_genes=20)
```

Example 56 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 57 (python):
```python
#adata.write('./ObjectsToUpload/Leukocytes.h5ad')
```

Example 58 (python):
```python
adata=sc.read('./ObjectsToUpload/Leukocytes.h5ad')
print(adata.shape)
```

Example 59 (unknown):
```unknown
(41046, 1745)
```

Example 60 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['MacrophagesATF3pos','MacrophagesCX3CR1pos','MacrophagesLYVE1pos','MacrophagesTIMD4pos','Monocytes','MonocyteDerivedCells','MonocytesMPOpos'])].copy()
adata
```

Example 61 (unknown):
```unknown
AnnData object with n_obs × n_vars = 17335 × 1745
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors', 'log1p', 't-test', 'rank_genes_groups'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 62 (python):
```python
set(adata.obs.fine_grain)
```

Example 63 (unknown):
```unknown
{'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos'}
```

Example 64 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='MacrophagesATF3pos'
sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 65 (python):
```python
ranking genes
    finished: added to `.uns['wilcoxon']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:19)
```

Example 66 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='MacrophagesCX3CR1pos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 67 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='MacrophagesLYVE1pos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 68 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='MacrophagesTIMD4pos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 69 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='MonocyteDerivedCells'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 70 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='Monocytes'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 71 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='MonocytesMPOpos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 72 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='MonocytesMPOpos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='Reactome_2022',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 73 (python):
```python
print(gene_set_names)
```

Example 74 (unknown):
```unknown
['ARCHS4_Cell-lines', 'ARCHS4_IDG_Coexp', 'ARCHS4_Kinases_Coexp', 'ARCHS4_TFs_Coexp', 'ARCHS4_Tissues', 'Achilles_fitness_decrease', 'Achilles_fitness_increase', 'Aging_Perturbations_from_GEO_down', 'Aging_Perturbations_from_GEO_up', 'Allen_Brain_Atlas_10x_scRNA_2021', 'Allen_Brain_Atlas_down', 'Allen_Brain_Atlas_up', 'Azimuth_Cell_Types_2021', 'BioCarta_2013', 'BioCarta_2015', 'BioCarta_2016', 'BioPlanet_2019', 'BioPlex_2017', 'CCLE_Proteomics_2020', 'CORUM', 'COVID-19_Related_Gene_Sets', 'COVID-19_Related_Gene_Sets_2021', 'Cancer_Cell_Line_Encyclopedia', 'CellMarker_Augmented_2021', 'ChEA_2013', 'ChEA_2015', 'ChEA_2016', 'ChEA_2022', 'Chromosome_Location', 'Chromosome_Location_hg19', 'ClinVar_2019', 'DSigDB', 'Data_Acquisition_Method_Most_Popular_Genes', 'DepMap_WG_CRISPR_Screens_Broad_CellLines_2019', 'DepMap_WG_CRISPR_Screens_Sanger_CellLines_2019', 'Descartes_Cell_Types_and_Tissue_2021', 'Diabetes_Perturbations_GEO_2022', 'DisGeNET', 'Disease_Perturbations_from_GEO_down', 'Disease_Perturbations_from_GEO_up', 'Disease_Signatures_from_GEO_down_2014', 'Disease_Signatures_from_GEO_up_2014', 'DrugMatrix', 'Drug_Perturbations_from_GEO_2014', 'Drug_Perturbations_from_GEO_down', 'Drug_Perturbations_from_GEO_up', 'ENCODE_Histone_Modifications_2013', 'ENCODE_Histone_Modifications_2015', 'ENCODE_TF_ChIP-seq_2014', 'ENCODE_TF_ChIP-seq_2015', 'ENCODE_and_ChEA_Consensus_TFs_from_ChIP-X', 'ESCAPE', 'Elsevier_Pathway_Collection', 'Enrichr_Libraries_Most_Popular_Genes', 'Enrichr_Submissions_TF-Gene_Coocurrence', 'Enrichr_Users_Contributed_Lists_2020', 'Epigenomics_Roadmap_HM_ChIP-seq', 'FANTOM6_lncRNA_KD_DEGs', 'GO_Biological_Process_2013', 'GO_Biological_Process_2015', 'GO_Biological_Process_2017', 'GO_Biological_Process_2017b', 'GO_Biological_Process_2018', 'GO_Biological_Process_2021', 'GO_Cellular_Component_2013', 'GO_Cellular_Component_2015', 'GO_Cellular_Component_2017', 'GO_Cellular_Component_2017b', 'GO_Cellular_Component_2018', 'GO_Cellular_Component_2021', 'GO_Molecular_Function_2013', 'GO_Molecular_Function_2015', 'GO_Molecular_Function_2017', 'GO_Molecular_Function_2017b', 'GO_Molecular_Function_2018', 'GO_Molecular_Function_2021', 'GTEx_Aging_Signatures_2021', 'GTEx_Tissue_Expression_Down', 'GTEx_Tissue_Expression_Up', 'GTEx_Tissues_V8_2023', 'GWAS_Catalog_2019', 'GeneSigDB', 'Gene_Perturbations_from_GEO_down', 'Gene_Perturbations_from_GEO_up', 'Genes_Associated_with_NIH_Grants', 'Genome_Browser_PWMs', 'GlyGen_Glycosylated_Proteins_2022', 'HDSigDB_Human_2021', 'HDSigDB_Mouse_2021', 'HMDB_Metabolites', 'HMS_LINCS_KinomeScan', 'HomoloGene', 'HuBMAP_ASCT_plus_B_augmented_w_RNAseq_Coexpression', 'HuBMAP_ASCTplusB_augmented_2022', 'HumanCyc_2015', 'HumanCyc_2016', 'Human_Gene_Atlas', 'Human_Phenotype_Ontology', 'IDG_Drug_Targets_2022', 'InterPro_Domains_2019', 'Jensen_COMPARTMENTS', 'Jensen_DISEASES', 'Jensen_TISSUES', 'KEA_2013', 'KEA_2015', 'KEGG_2013', 'KEGG_2015', 'KEGG_2016', 'KEGG_2019_Human', 'KEGG_2019_Mouse', 'KEGG_2021_Human', 'KOMP2_Mouse_Phenotypes_2022', 'Kinase_Perturbations_from_GEO_down', 'Kinase_Perturbations_from_GEO_up', 'L1000_Kinase_and_GPCR_Perturbations_down', 'L1000_Kinase_and_GPCR_Perturbations_up', 'LINCS_L1000_CRISPR_KO_Consensus_Sigs', 'LINCS_L1000_Chem_Pert_Consensus_Sigs', 'LINCS_L1000_Chem_Pert_down', 'LINCS_L1000_Chem_Pert_up', 'LINCS_L1000_Ligand_Perturbations_down', 'LINCS_L1000_Ligand_Perturbations_up', 'Ligand_Perturbations_from_GEO_down', 'Ligand_Perturbations_from_GEO_up', 'MAGMA_Drugs_and_Diseases', 'MCF7_Perturbations_from_GEO_down', 'MCF7_Perturbations_from_GEO_up', 'MGI_Mammalian_Phenotype_2013', 'MGI_Mammalian_Phenotype_2017', 'MGI_Mammalian_Phenotype_Level_3', 'MGI_Mammalian_Phenotype_Level_4', 'MGI_Mammalian_Phenotype_Level_4_2019', 'MGI_Mammalian_Phenotype_Level_4_2021', 'MSigDB_Computational', 'MSigDB_Hallmark_2020', 'MSigDB_Oncogenic_Signatures', 'Metabolomics_Workbench_Metabolites_2022', 'Microbe_Perturbations_from_GEO_down', 'Microbe_Perturbations_from_GEO_up', 'Mouse_Gene_Atlas', 'NCI-60_Cancer_Cell_Lines', 'NCI-Nature_2015', 'NCI-Nature_2016', 'NIH_Funded_PIs_2017_AutoRIF_ARCHS4_Predictions', 'NIH_Funded_PIs_2017_GeneRIF_ARCHS4_Predictions', 'NIH_Funded_PIs_2017_Human_AutoRIF', 'NIH_Funded_PIs_2017_Human_GeneRIF', 'NURSA_Human_Endogenous_Complexome', 'OMIM_Disease', 'OMIM_Expanded', 'Old_CMAP_down', 'Old_CMAP_up', 'Orphanet_Augmented_2021', 'PFOCR_Pathways', 'PPI_Hub_Proteins', 'PanglaoDB_Augmented_2021', 'Panther_2015', 'Panther_2016', 'Pfam_Domains_2019', 'Pfam_InterPro_Domains', 'PheWeb_2019', 'PhenGenI_Association_2021', 'Phosphatase_Substrates_from_DEPOD', 'ProteomicsDB_2020', 'Proteomics_Drug_Atlas_2023', 'RNA-Seq_Disease_Gene_and_Drug_Signatures_from_GEO', 'RNAseq_Automatic_GEO_Signatures_Human_Down', 'RNAseq_Automatic_GEO_Signatures_Human_Up', 'RNAseq_Automatic_GEO_Signatures_Mouse_Down', 'RNAseq_Automatic_GEO_Signatures_Mouse_Up', 'Rare_Diseases_AutoRIF_ARCHS4_Predictions', 'Rare_Diseases_AutoRIF_Gene_Lists', 'Rare_Diseases_GeneRIF_ARCHS4_Predictions', 'Rare_Diseases_GeneRIF_Gene_Lists', 'Reactome_2013', 'Reactome_2015', 'Reactome_2016', 'Reactome_2022', 'SILAC_Phosphoproteomics', 'Serine_Threonine_Kinome_Atlas_2023', 'SubCell_BarCode', 'SynGO_2022', 'SysMyo_Muscle_Gene_Sets', 'TF-LOF_Expression_from_GEO', 'TF_Perturbations_Followed_by_Expression', 'TG_GATES_2020', 'TRANSFAC_and_JASPAR_PWMs', 'TRRUST_Transcription_Factors_2019', 'Table_Mining_of_CRISPR_Studies', 'Tabula_Muris', 'Tabula_Sapiens', 'TargetScan_microRNA', 'TargetScan_microRNA_2017', 'Tissue_Protein_Expression_from_Human_Proteome_Map', 'Tissue_Protein_Expression_from_ProteomicsDB', 'Transcription_Factor_PPIs', 'UK_Biobank_GWAS_v1', 'Virus-Host_PPI_P-HIPSTer_2020', 'VirusMINT', 'Virus_Perturbations_from_GEO_down', 'Virus_Perturbations_from_GEO_up', 'WikiPathway_2021_Human', 'WikiPathways_2013', 'WikiPathways_2015', 'WikiPathways_2016', 'WikiPathways_2019_Human', 'WikiPathways_2019_Mouse', 'dbGaP', 'huMAP', 'lncHUB_lncRNA_Co-Expression', 'miRTarBase_2017']
```

Example 75 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 76 (unknown):
```unknown
(297473, 36601)
```

Example 77 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['MacrophagesATF3pos','MacrophagesCX3CR1pos','MacrophagesLYVE1pos','MacrophagesTIMD4pos','Monocytes','MonocyteDerivedCells','MonocytesMPOpos'])].copy()
adata
```

Example 78 (unknown):
```unknown
AnnData object with n_obs × n_vars = 17335 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 79 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 80 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:08)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1387
```

Example 81 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    413 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['BIRC5', 'NDC80', 'NUF2', 'TMPO', 'TACC3', 'CKAP2L', 'AURKB', 'ANP32E', 'KIF20B', 'HJURP', 'CDCA3', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'AURKA', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'CBX5', 'CENPA']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    488 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 82 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 83 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [01:12<00:00,  1.44s/it, loss=659, v_num=1]
```

Example 84 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'ZFP36', 'CEBPD', 'CEBPB', 'HSP90AB1', 'HSPA8', 'HSPE1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    337 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    343 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:04)
```

Example 85 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 86 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 87 (python):
```python
adata=adata[adata.obs.cycling=='no',:].copy()
```

Example 88 (python):
```python
#This box to run enrichment right away
ClusterOfInterest='MacrophagesATF3pos'
sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)

#This box to run enrichment right away
ClusterOfInterest='MacrophagesCX3CR1pos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)

#This box to run enrichment right away
ClusterOfInterest='MacrophagesLYVE1pos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)

#This box to run enrichment right away
ClusterOfInterest='MacrophagesTIMD4pos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)

#This box to run enrichment right away
ClusterOfInterest='MonocyteDerivedCells'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)

#This box to run enrichment right away
ClusterOfInterest='Monocytes'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)

#This box to run enrichment right away
ClusterOfInterest='MonocytesMPOpos'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='wilcoxon', key_added = "wilcoxon")
gene_set_names = gseapy.get_library_name(organism='Human')
#print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group=ClusterOfInterest, 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
#print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
gseapy.barplot(enr_res.res2d,title=ClusterOfInterest,top_term=20,figsize=(5,5))
#enr_res.results.head(20)
```

Example 89 (python):
```python
ranking genes
    finished: added to `.uns['wilcoxon']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:15)
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Mesenchymal/ViolinPlots.html

**Contents:**
- Violin plots¶

**Examples:**

Example 1 (unknown):
```unknown
#General figures codes
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-05-11 19:31.
```

Example 5 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(297473, 36601)
```

Example 7 (python):
```python
set(adata.obs.fine_grain)
```

Example 8 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 9 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 10 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 11 (python):
```python
#Expression: "YlGn" (e.g. DE plots)
#Divergent expression: "PRGn" (e.g. log2FC)
#Age: "afmhot_r"
#Others: "viridis" (e.g. UMAP expression)

#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodePacemakerCells':'#854834',
    'AtrioventricularNodePacemakerCells':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 12 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryPericytes','CoronarySmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','GreatVesselSmoothMuscleCells'])].copy()
adata=adata[adata.obs.coarse_grain=='Cardiomyocytea',:].copy()
set(adata.obs.fine_grain)
```

Example 13 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'SinoatrialNodePacemakerCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 14 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 15 (unknown):
```unknown
normalizing counts per cell
    finished (0:00:00)
```

Example 16 (python):
```python
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/tmp/ipykernel_189866/3224076617.py in <module>
      4 # normalise and log-transform
      5 sc.pp.normalize_total(adata, target_sum=1e4)
----> 6 sc.pp.log1p(adata)
      7 
      8 sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

~/miniconda3/envs/scanpynew/lib/python3.8/functools.py in wrapper(*args, **kw)
    873                             '1 positional argument')
    874 
--> 875         return dispatch(args[0].__class__)(*args, **kw)
    876 
    877     funcname = getattr(func, '__name__', 'singledispatch function')

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/preprocessing/_simple.py in log1p_anndata(adata, base, copy, chunked, chunk_size, layer, obsm)
    382     else:
    383         X = _get_obs_rep(adata, layer=layer, obsm=obsm)
--> 384         X = log1p(X, copy=False, base=base)
    385         _set_obs_rep(adata, X, layer=layer, obsm=obsm)
    386 

~/miniconda3/envs/scanpynew/lib/python3.8/functools.py in wrapper(*args, **kw)
    873                             '1 positional argument')
    874 
--> 875         return dispatch(args[0].__class__)(*args, **kw)
    876 
    877     funcname = getattr(func, '__name__', 'singledispatch function')

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/preprocessing/_simple.py in log1p_sparse(X, base, copy)
    335         X, accept_sparse=("csr", "csc"), dtype=(np.float64, np.float32), copy=copy
    336     )
--> 337     X.data = log1p(X.data, copy=False, base=base)
    338     return X
    339 

~/miniconda3/envs/scanpynew/lib/python3.8/functools.py in wrapper(*args, **kw)
    873                             '1 positional argument')
    874 
--> 875         return dispatch(args[0].__class__)(*args, **kw)
    876 
    877     funcname = getattr(func, '__name__', 'singledispatch function')

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/preprocessing/_simple.py in log1p_array(X, base, copy)
    350     elif not (np.issubdtype(X.dtype, np.floating) or np.issubdtype(X.dtype, complex)):
    351         X = X.astype(float)
--> 352     np.log1p(X, out=X)
    353     if base is not None:
    354         np.divide(X, np.log(base), out=X)

KeyboardInterrupt:
```

Example 17 (python):
```python
#Fibroblasts
#adata.obs['type']= 'na'
#adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts']]]='Heart'
#adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselAdventitialFibroblasts']]]='GreatVessels'
#sc.pl.umap(adata, color='type')

#Endothelium
#adata.obs['type']= 'na'
#adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells']]]='Heart'
#adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells']]]='GreatVessels'
#sc.pl.umap(adata, color='type')

#SmoothMuscleCells
adata.obs['type']= 'na'
adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['CoronaryPericytes','CoronarySmoothMuscleCells']]]='Heart'
adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['DuctusArteriosusSmoothMuscleCells','GreatVesselSmoothMuscleCells']]]='GreatVessels'
sc.pl.umap(adata, color='type')
```

Example 18 (unknown):
```unknown
... storing 'type' as categorical
```

Example 19 (python):
```python
sc.tl.rank_genes_groups(adata, 'type', method='wilcoxon', key_added = "wilcoxon")
result = adata.uns['wilcoxon']
groups = result['names'].dtype.names
df = pd.DataFrame(
{group + '_' + key[:5]: result[key][group]
for group in groups for key in ['names','scores','logfoldchanges','pvals','pvals_adj']})
df.to_csv('./FibroblastsDE.csv')
```

Example 20 (python):
```python
ranking genes
    finished: added to `.uns['wilcoxon']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:02:21)
```

Example 21 (python):
```python
#This box to run enrichment right away
gene_set_names = gseapy.get_library_name(organism='Human')
print(gene_set_names)

glist = sc.get.rank_genes_groups_df(adata, group='GreatVessels', 
                                    key='wilcoxon', log2fc_min=0, 
                                    pval_cutoff=1)['names'].squeeze().str.strip().tolist()
print(len(glist))

#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
enr_res.results.head()
```

Example 22 (python):
```python
adata=sc.read('./ViolinPlot/FibroblastViolinFigures.h5ad')
adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
sc.tl.rank_genes_groups(adata, 'heart_or_greatvessels', groups=['heart'], reference='greatvessels', method='t-test')
plt.rcParams['figure.figsize'] = 6,5
sc.pl.rank_genes_groups_violin(adata, groups='heart',gene_names=['TBX20','SCN7A','MOXD1','SPON2','TCF21','TSHZ2','ROR1','PIEZO2','MEIS1','SFRP2'],strip=False)
#adata.write('./ViolinPlot/FibroblastViolinFigures.h5ad')
```

Example 23 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
```

Example 24 (python):
```python
ClusterOfInterest='GreatVesselAdventitialFibroblasts'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 25 (python):
```python
#Muralcells
adata=sc.read('./ViolinPlot/MuralViolinFigures.h5ad')
print(adata.shape)
sc.tl.rank_genes_groups(adata, 'heart_or_greatvessels', groups=['heart'], reference='greatvessels', method='t-test')
plt.rcParams['figure.figsize'] = 6,5
sc.pl.rank_genes_groups_violin(adata, groups='heart',gene_names=['NR2F2','TFPI','TBX2','ENPEP','COL18A1','ERBB4','THSD4','SFRP1','FBLN5','PRDM6'],strip=False)
#adata.write('./ViolinPlot/MuralViolinFigures.h5ad')
```

Example 26 (python):
```python
(28497, 1505)
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 27 (python):
```python
#Endothelial
adata=sc.read('./ViolinPlot/EndothelialViolinFigures.h5ad')
print(adata.shape)
sc.tl.rank_genes_groups(adata, 'heart_or_greatvessels', groups=['heart'], reference='greatvessels', method='t-test')
plt.rcParams['figure.figsize'] = 6,5
sc.pl.rank_genes_groups_violin(adata, groups='heart',gene_names=['COL4A1','COL4A2','H19','A2M','ADGRL4','HMCN1','COL3A1','NRG3','MEIS2','PLXNA4'],strip=False)
#adata.write('./ViolinPlot/EndothelialViolinFigures.h5ad')
```

Example 28 (python):
```python
(11352, 1634)
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_fibroblasts.html

**Contents:**
- Variables¶
- Read in data¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 0 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-09 22:58
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'Fibroblasts'
```

Example 10 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 49242 × 4999
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([4.2093534, 2.6576407, 2.6576407, 3.3151019, 3.3151019],
      dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 36.3 s, sys: 367 ms, total: 36.7 s
Wall time: 36.8 s
```

Example 21 (python):
```python
# markers for fine-grained cell types
sc_markers = pd.read_csv(f'/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_{celltype}_finegrain_markers.csv',
                         index_col=0)
markers = {}
n_top = 30
for c in set(sc_markers['group']):
    markers_sub = sc_markers[sc_markers['group']==c]
    markers_sub.sort_values('logfoldchanges',ascending=False)
    markers[c]=list(markers_sub[:n_top]['names'])

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]
genes = list(set(genes))
len(genes)
```

Example 22 (unknown):
```unknown
resolution_sel = 0.6
```

Example 23 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 24 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: ValveInterstitialCells, Myofibroblasts, LymphNodeFibroblasticReticularCells, etc.
```

Example 25 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 26 (unknown):
```unknown
[4.2093534 2.6576407 2.6576407 3.3151019 3.3151019]
```

Example 27 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 28 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 29 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'unassigned',
    '1':'Fibroblasts',
    '2':'Fibroblasts',
    '3':'Fibroblasts',
    '4':'Fibroblasts',
    '5':'Fibroblasts',
    '6':'Fibroblasts',
    '7':'Fibroblasts',
    '8':'Fibroblasts',
    '9':'Fibroblasts',
    '10':'Fibroblasts',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 30 (python):
```python
/tmp/ipykernel_71001/632585045.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 31 (unknown):
```unknown
tmp_annotation
Fibroblasts    39604
unassigned      9638
Name: count, dtype: int64
```

Example 32 (unknown):
```unknown
'Fibroblasts'
```

Example 33 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 34 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['Fibroblasts'])]
```

Example 35 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 36 (unknown):
```unknown
AnnData object with n_obs × n_vars = 39604 × 4999
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.6', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 37 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 38 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 39604 × 4522
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.6', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 39 (python):
```python
'''
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
'''
```

Example 40 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 41 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
```

Example 42 (unknown):
```unknown
number of hvgs: 732
```

Example 43 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-06-09 23:01:48,070 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-09 23:01:51,731 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-09 23:01:51,859 - harmonypy - INFO - Iteration 1 of 10
2025-06-09 23:01:58,543 - harmonypy - INFO - Iteration 2 of 10
2025-06-09 23:02:06,203 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 44 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 45 (unknown):
```unknown
CPU times: user 1min 18s, sys: 734 ms, total: 1min 19s
Wall time: 1min 19s
```

Example 46 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 47 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=['TOP2A','MKI67'],
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 48 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=["conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 49 (unknown):
```unknown
sub_resolution_sel = 0.6
```

Example 50 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 51 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: ValveInterstitialCells, Myofibroblasts, LymphNodeFibroblasticReticularCells, etc.
```

Example 52 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 53 (unknown):
```unknown
[4.2093534 2.6576407 2.6576407 3.3151019 3.3151019]
```

Example 54 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 55 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=['celltypist_midmod2fine', 'conf_score_midmod2fine'],
                wspace=0.7)
```

Example 56 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'Fibroblasts',
    '1':'Fibroblasts',
    '2':'Fibroblasts',
    '3':'FibroblastsCycling',
    '4':'Fibroblasts',
    '5':'Fibroblasts',
    '6':'Fibroblasts',
    '7':'FibroblastsCOL2A1pos',
    '8':'Fibroblasts',
    '9':'Fibroblasts',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 57 (python):
```python
/tmp/ipykernel_71001/4045297513.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 58 (unknown):
```unknown
fine_grain_manual
Fibroblasts             32842
FibroblastsCycling       4133
FibroblastsCOL2A1pos     2629
Name: count, dtype: int64
```

Example 59 (unknown):
```unknown
'Fibroblasts'
```

Example 60 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 61 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 62 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 63 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
                  spot_size=60,vmax='p100')
```

Example 64 (python):
```python
/tmp/ipykernel_71001/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 65 (python):
```python
/tmp/ipykernel_71001/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 66 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=80,vmax='p100')
```

Example 67 (python):
```python
/tmp/ipykernel_71001/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 68 (python):
```python
/tmp/ipykernel_71001/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 69 (python):
```python
/tmp/ipykernel_71001/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 70 (python):
```python
/tmp/ipykernel_71001/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 71 (python):
```python
/tmp/ipykernel_71001/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 72 (python):
```python
/tmp/ipykernel_71001/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 73 (python):
```python
/tmp/ipykernel_71001/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 74 (python):
```python
/tmp/ipykernel_71001/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 75 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 76 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_Fibroblasts_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no02_add_celltypist_prediction.html

**Contents:**
- Variables¶
- Read in data¶
- Add celltypist prediction results¶
- Save¶

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import celltypist
```

Example 2 (python):
```python
# import session_info
# session_info.show()
```

Example 3 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 4 (unknown):
```unknown
os.getcwd()
```

Example 5 (unknown):
```unknown
'/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/Xenium/5K/C194_Hst45/CamU'
```

Example 6 (unknown):
```unknown
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
```

Example 7 (python):
```python
adata = sc.read_h5ad(f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad')
adata
```

Example 8 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    obsm: 'spatial'
```

Example 9 (python):
```python
adata.X.data[:5]
```

Example 10 (unknown):
```unknown
array([5., 1., 1., 2., 2.], dtype=float32)
```

Example 11 (unknown):
```unknown
columns_to_transfer = ['celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod',
                       'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine']
```

Example 12 (python):
```python
c194 = sc.read_h5ad(f'{objects_dir}/C194-HEA-0-FFPE-1_5K_filtered_lognorm.h5ad',
                    backed='r'
                   )
hst45 = sc.read_h5ad(f'{objects_dir}/Hst45-HEA-0-FFPE-1_5K_filtered_lognorm.h5ad',
                    backed='r'
                   )
```

Example 13 (python):
```python
print(c194.obs[columns_to_transfer].isna().sum())
print(hst45.obs[columns_to_transfer].isna().sum())
```

Example 14 (unknown):
```unknown
celltypist_coarse              0
conf_score_coarse              0
celltypist_coarse_fin          0
celltypist_coarse2midmod    4000
conf_score_coarse2midmod    4000
celltypist_mid_fin             0
celltypist_midmod2fine      6917
conf_score_midmod2fine      6917
dtype: int64
celltypist_coarse              0
conf_score_coarse              0
celltypist_coarse_fin          0
celltypist_coarse2midmod    2081
conf_score_coarse2midmod    2081
celltypist_mid_fin             0
celltypist_midmod2fine      4724
conf_score_midmod2fine      4724
dtype: int64
```

Example 15 (unknown):
```unknown
# update obsnames
c194.obs_names = list('C194-HEA-0-FFPE-1_'+c194.obs_names.astype('str'))
hst45.obs_names = list('Hst45-HEA-0-FFPE-1_'+hst45.obs_names.astype('str'))
```

Example 16 (python):
```python
# add
adata.obs[columns_to_transfer] = np.nan
adata.obs.loc[c194.obs_names,columns_to_transfer] = c194.obs[columns_to_transfer]
adata.obs.loc[hst45.obs_names,columns_to_transfer] = hst45.obs[columns_to_transfer]
```

Example 17 (python):
```python
# check if there's rows missing prediction results
adata.obs[columns_to_transfer].isna().sum()
```

Example 18 (unknown):
```unknown
celltypist_coarse               0
conf_score_coarse               0
celltypist_coarse_fin           0
celltypist_coarse2midmod     6081
conf_score_coarse2midmod     6081
celltypist_mid_fin              0
celltypist_midmod2fine      11641
conf_score_midmod2fine      11641
dtype: int64
```

Example 19 (python):
```python
adata.write(f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad')
f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
```

Example 20 (unknown):
```unknown
... storing 'celltypist_coarse' as categorical
... storing 'celltypist_coarse_fin' as categorical
... storing 'celltypist_coarse2midmod' as categorical
... storing 'celltypist_mid_fin' as categorical
... storing 'celltypist_midmod2fine' as categorical
```

Example 21 (unknown):
```unknown
'/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
```

Example 22 (python):
```python
adata.X.data[:5]
```

Example 23 (unknown):
```unknown
array([5., 1., 1., 2., 2.], dtype=float32)
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Visium/Visium_Intagration-Annotation/Visium_integration_no1_bbknn.html

**Contents:**
- Functions¶
- Read in visium anndata¶
- Clustering using cell2location output¶
- with batch correction¶
- Save¶

**Examples:**

Example 1 (python):
```python
import sys
import scanpy as sc
import anndata
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt 
import matplotlib as mpl

from matplotlib import rcParams
rcParams['pdf.fonttype'] = 42 # enables correct plotting of text
import seaborn as sns

import bbknn

import milopy.core as milo
import milopy.plot as milopl

import os
```

Example 2 (python):
```python
sc.settings.set_figure_params(dpi=120)
```

Example 3 (python):
```python
# This function selects the data for multiple slides from the spatial anndata object.
# Modified `select_slide` in cell2loc for multiple slides

# @param adata: anndata object with multiple spatial experiments
# @param s: list of selected slides
# @param s_col: column in adata.obs listing experiment name for each location

def select_multislide(adata, s, s_col='sample'):

    slides = adata[adata.obs[s_col].isin(s), :]
    s_keys = list(slides.uns['spatial'].keys())
    
    uns_dict = {}
    for ss in s:
        s_spatial=np.array(s_keys)[[ss in k for k in s_keys]][0]
        uns_dict[s_spatial]=slides.uns['spatial'][s_spatial]
    
    slides.uns['spatial'] = uns_dict

    return slides
```

Example 4 (unknown):
```unknown
!ls /nfs/team205/heart/anndata_objects/Foetal
```

Example 5 (python):
```python
14Feb_fromSemih		      RNA_foetal_post-scVI_raw.h5ad
archive			      RNA_foetal_raw.h5ad
Feb28ObjectRaw.h5ad	      scArches
Feb28ObjectRaw_Multiome.h5ad  scVI
Feb28ObjectRaw_Multiome.rds   trisomy21
Feb28ObjectRaw.obs.csv	      visium-FFPE_foetal_raw.h5ad
Feb28ObjectRaw_original.h5ad  visium_foetal_healthy-all_raw.h5ad
Feb28ObjectRaw_re-scVI.h5ad   visium_foetal_raw.h5ad
He_Cell_foetal-lung	      visium-OCT_foetal_acrossage_raw.h5ad
Immune			      visium-OCT_foetal_DuctusA_raw.h5ad
metadata		      visium-OCT_foetal_raw.h5ad
multiome_ATAC		      visium-OCT-LV_foetal_raw.h5ad
QC
```

Example 6 (python):
```python
adata_oct = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-OCT_foetal_raw.h5ad')

adata_da = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-OCT_foetal_DuctusA_raw.h5ad')
adata_da.obs['sample_for_cell2loc'] = adata_da.obs['sample'].copy()

# adata_lv = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-OCT-LV_foetal_raw.h5ad')

adata_ffpe = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-FFPE_foetal_raw.h5ad')
adata_ffpe.obs['sample_for_cell2loc'] = adata_ffpe.obs['sample'].copy()
adata_ffpe.obs['cell2loc-map_group'] = 'FFPE_16PCW'
```

Example 7 (python):
```python
adata_vis = adata_oct.concatenate(
        [adata_da,adata_ffpe], # adata_lv,
        batch_key=None,
        # uns_merge="unique",
        index_unique=None,
        join="outer")
adata_vis
```

Example 8 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1785: FutureWarning: X.dtype being converted to np.float32 from float64. In the next version of anndata (0.9) conversion will not be automatic. Pass dtype explicitly to avoid this warning. Pass `AnnData(X, dtype=X.dtype, ...)` to get the future behavour.
  [AnnData(sparse.csr_matrix(a.shape), obs=a.obs) for a in all_adatas],
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 39563 × 33562
    obs: 'in_tissue', 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'cell2loc-map_group', 'JC_edit', 'sample_for_cell2loc'
    var: 'gene_ids-0', 'feature_types-0', 'genome-0', 'SYMBOL-0', 'mt-0', 'gene_ids-1', 'feature_types-1', 'genome-1', 'SYMBOL-1', 'mt-1', 'gene_ids-2', 'feature_types-2', 'genome-2', 'SYMBOL-2', 'mt-2'
    obsm: 'MT', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
```

Example 10 (python):
```python
pd.crosstab(adata_vis.obs['sample_for_cell2loc'],adata_vis.obs['cell2loc-map_group'])
```

Example 11 (python):
```python
pd.crosstab(adata_vis.obs['cell2loc-map_group'],adata_vis.obs['JC_edit'],)
```

Example 12 (python):
```python
# make complete SYMBOL column
na_index = adata_vis.var_names[adata_vis.var['SYMBOL-0'].isna()]
adata_vis.var['SYMBOL'] = adata_vis.var['SYMBOL-0'].copy()
adata_vis.var.loc[na_index,'SYMBOL'] = adata_vis.var.loc[na_index,'SYMBOL-2']
adata_vis.var = adata_vis.var[['SYMBOL']]
sum(adata_vis.var['SYMBOL'].isna())
```

Example 13 (python):
```python
# fillna
# "DuctusArteriosusSmoothMuscleCells"
adata_vis.obsm['q05_cell_abundance_w_sf'] = adata_vis.obsm['q05_cell_abundance_w_sf'].fillna(0)
```

Example 14 (python):
```python
# set symboßl as var_names
adata_vis.var['gene_ids'] = adata_vis.var_names.copy()
adata_vis.var.set_index('SYMBOL',inplace=True)

adata_vis
```

Example 15 (unknown):
```unknown
AnnData object with n_obs × n_vars = 39563 × 33562
    obs: 'in_tissue', 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'cell2loc-map_group', 'JC_edit', 'sample_for_cell2loc'
    var: 'gene_ids'
    obsm: 'MT', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
```

Example 16 (python):
```python
# remove Cavity
# filter out spots: remove 'Cavity'
adata_vis = adata_vis[adata_vis.obs['JC_edit'].isin(['Cavity'])==False]
```

Example 17 (python):
```python
# set 'week'
adata_vis.obs['week'] = adata_vis.obs['cell2loc-map_group'].astype('str').copy()
adata_vis.obs.replace({'week':{
    '13PCW':'13W', 
    '20PCW':'20W',
    '4PCW':'4W',
    '5PCW':'5W',
    '7PCW':'7W',
    '7PCW_DA':'7W',
    'FFPE_16PCW':'16W'
}},inplace=True)
```

Example 18 (unknown):
```unknown
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/ipykernel_launcher.py:2: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 19 (python):
```python
adata_vis.var.head()
```

Example 20 (python):
```python
len(set(adata_vis.obs['sample_for_cell2loc']))
```

Example 21 (python):
```python
# compute KNN using the cell2location output stored in adata.obsm
# input of use_rep should be numpy.ndarray
adata_vis.obsm['q05_cell_abundance_w_sf_ndarray'] = np.array(adata_vis.obsm['q05_cell_abundance_w_sf'])
# bbknn
bbknn.bbknn(adata_vis, batch_key='sample_for_cell2loc', use_rep='q05_cell_abundance_w_sf_ndarray')

# Cluster spots into regions using scanpy
sc.tl.leiden(adata_vis, resolution=1.5)

# add region as categorical variable
adata_vis.obs["region_cluster"] = adata_vis.obs["leiden"].astype("category")
```

Example 22 (python):
```python
'''
# harmony
import scanpy.external as sce
sce.pp.harmony_integrate(adata_vis, 'sample_for_cell2loc', basis='q05_cell_abundance_w_sf_ndarray', adjusted_basis='X_cell2loc_harmony')

# compute KNN using the cell2location output stored in adata.obsm
sc.pp.neighbors(adata_vis, use_rep='X_cell2loc_harmony',
                n_neighbors = 10)

# Cluster spots into regions using scanpy
sc.tl.leiden(adata_vis, resolution=0.5)

# add region as categorical variable
adata_vis.obs["region_cluster"] = adata_vis.obs["leiden"].astype("category")
'''
```

Example 23 (python):
```python
# compute UMAP using KNN graph based on the cell2location output
sc.tl.umap(adata_vis, min_dist = 0.2, spread = 1)  # n_components=3
```

Example 24 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['region_cluster','sample_for_cell2loc'], size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False, components='all')
```

Example 25 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [4, 6]}):
    sc.pl.umap(adata_vis, color=['JC_edit','cell2loc-map_group'], size=5,
               color_map = 'RdPu', ncols = 1, wspace=0.7,components='all',
               legend_fontsize=14, frameon=False)
```

Example 26 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['JC_edit'], groups='AVN', size=5,
               color_map = 'RdPu', ncols = 1, wspace=0.7,
               legend_fontsize=14, frameon=False)
```

Example 27 (python):
```python
adata_vis.obs.drop('in_tissue',axis=1,inplace=True)
adata_vis.obs['array_row'] = adata_vis.obs['array_row'].astype('int')
adata_vis.obs['array_col'] = adata_vis.obs['array_col'].astype('int')
adata_vis.write('/nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_raw.h5ad')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no8_plotting_for-Fig.html

**Contents:**
- Read in adata¶
- Log-normalisation¶
- Plot cell types¶
- UMAP¶
- TissueTypist niches¶

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42
```

Example 2 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 3 (unknown):
```unknown
os.getcwd()
```

Example 4 (unknown):
```unknown
'/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/Xenium/5K/C194_Hst45/CamU'
```

Example 5 (unknown):
```unknown
figdir = '/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/fetal_ms_figures'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 6 (unknown):
```unknown
celltype_key = 'fine_grain_12Jun2025'
```

Example 7 (python):
```python
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
adata
```

Example 8 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'fine_grain_12Jun2025', 'sliding_window_assignment', 'window_col', 'window_row', 'globalX', 'globalY', 'tt_prediction'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'dendrogram_pca_harmony_leiden_1.0', 'fine_grain_12Jun2025_colors', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 9 (unknown):
```unknown
os.getcwd()
```

Example 10 (unknown):
```unknown
'/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/Xenium/5K/C194_Hst45/CamU'
```

Example 11 (python):
```python
adata.X.data[:5]
```

Example 12 (unknown):
```unknown
array([5., 1., 1., 2., 2.], dtype=float32)
```

Example 13 (python):
```python
# celltype name mapping for plotting
df = pd.read_csv('/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/finegrain_name_mapping.csv')
celltype_mapping = df.set_index('Full_name')['Short_name_finalised'].to_dict()
adata.obs.replace({celltype_key:celltype_mapping},inplace=True)
```

Example 14 (python):
```python
/tmp/ipykernel_968450/407166641.py:4: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({celltype_key:celltype_mapping},inplace=True)
```

Example 15 (python):
```python
# log-normalise the count
sc.pp.normalize_total(adata,target_sum=1e4)
sc.pp.log1p(adata)
adata.X.data[:5]
```

Example 16 (unknown):
```unknown
array([4.2093534, 2.6576407, 2.6576407, 3.3151019, 3.3151019],
      dtype=float32)
```

Example 17 (python):
```python
set(adata.obs[celltype_key])
```

Example 18 (unknown):
```unknown
{'?EpendymalCells',
 '?EpithelialCells',
 '?SkeletalMuscle',
 '?ThyroidCells',
 'AVNPC',
 'AtrialCardiomyocytes_DoubletWithEC',
 'AtrialCardiomyocytes_DoubletWithFB',
 'B',
 'ChromC',
 'CorArtEC',
 'CorCapEC',
 'CorCapECCyc',
 'CorCapECN',
 'CorPeri',
 'CorSMC',
 'CorVenEC',
 'CoronaryCapillaryEndothelialCells_DoubletsWithEryth',
 'DASMC',
 'DC',
 'ELNeuro',
 'EPDC',
 'EndoCush',
 'Endocard',
 'EndocardCyc',
 'EndocardialCells_Doublets',
 'Eryth',
 'ErythCyc',
 'FB',
 'FBCOL2A1',
 'FBCyc',
 'GVArtEC',
 'GVSMC',
 'GVSMCCyc',
 'GVVenEC',
 'ILC',
 'LymphEC',
 'MPLYVE1',
 'MacCX3',
 'MastC',
 'MegaK',
 'MesEpiC',
 'Mono',
 'MyeloidCells_Doublets',
 'NeuroPre',
 'ParaN',
 'PericCyc',
 'PericFib',
 'PericInt',
 'SANPC',
 'SOX2_LAMB3_pos',
 'SchwC',
 'SchwCyc',
 'SchwP',
 'SchwannCells_DoubletsWithNeurons',
 'SympN',
 'TCD4',
 'TCD8',
 'ThyroidEpithelialCells',
 'VCSDist',
 'ValveEC',
 'aCMCyc',
 'aCML',
 'aCMR',
 'doublets',
 'unassigned',
 'unclassified',
 'vCM',
 'vCMCyc'}
```

Example 19 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

sc.pl.spatial(slide,color=[celltype_key],
              spot_size=15,vmax='p100',
              crop_coord=(4600,5600,4250,5250)
             )
```

Example 20 (python):
```python
/tmp/ipykernel_3227243/3010556783.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=[celltype_col],
```

Example 21 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

celltypes_list = ['AVNPC', 'CorCapEC', 'CorPeri', 'DASMC', 'EPDC', 'EndoCush', 'Endocard',
       'Eryth', 'FB', 'GVSMC', 'GVSMCT', 'GVVenEC', 'LymphEC', 'MPLYVE1',
       'MacCX3', 'MesEpiC', 'MoDC', 'ParaN', 'PericFib', 'SANPC', 'SchwC',
       'SchwNeuro', 'ValveEC', 'ValveIC', 'aCML', 'aCMR']
color_list = ['#ffff00',
 '#1ce6ff',
 '#ff34ff',
 '#a30059',
 '#ffdbe5',
 '#63ffac',
 '#b79762',
 '#004d43',
 '#8fb0ff',
 '#997d87',
 '#5a0007',
 'red',
 '#4a3b53',
 '#ff2f80',
 '#ba0900',
 '#6b7900',
 '#00c2a0',
 'blue',
 '#b903aa',
 (0.5, 0.0, 0.5, 0.7),
 '#7b4f4b',
 '#013349',
 '#00846f',
 '#372101',
 '#ffb500',
 '#c2ffed',
 '#cc0744',
 '#c0b9b2']

for celltype,color in zip(celltypes_list,color_list):
    # update colors
    if celltype in set(slide.obs[celltype_key]):
        slide.uns[f"{celltype_key}_colors"][list(slide.obs[celltype_key].cat.categories).index(celltype)]=color

celltypes_to_plot = ['SANPC',
                     'CorCapEC',
                     'CorPeri',
                     'GVVenEC',
                     'MesEpiC',
                     'FB',
                     'aCMR',
                     'AVNPC',
                     'ParaN',
                     'SchwP',
                    ]

sc.pl.spatial(slide,color=[celltype_key],groups=celltypes_to_plot,
              spot_size=15,vmax='p100',
              crop_coord=(4600,5600,4250,5250),
              show=False
             )
plt.savefig(f'{figdir}/Xenium5K_euploid_SAN_for-Fig1.pdf',bbox_inches="tight",dpi=300)
```

Example 22 (python):
```python
/tmp/ipykernel_3227243/2717981830.py:54: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=[celltype_key],groups=celltypes_to_plot,
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/plotting/_utils.py:406: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns[color_key] = _palette
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/plotting/_tools/scatterplots.py:1148: UserWarning: *c* argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with *x* & *y*.  Please use the *color* keyword-argument or provide a 2D array with a single row if you intend to specify the same RGB or RGBA value for all points.
  ax.scatter([], [], c=palette[label], label=label)
```

Example 23 (python):
```python
ADATA_PATH = "/rfs/project/rfs-iCNyzSAaucw/kk837/data_objects/Foetal/RNA/Feb28ObjectRaw_finegrain_updated.h5ad"
ad = sc.read_h5ad(ADATA_PATH, backed='r')

# Step 1: Create mapping (already done)
cat = "mid_grain"
mid2colours = dict(zip(ad.obs[cat].cat.categories, ad.uns[f"{cat}_colors"]))

# Step 2: Extract the labels and colors in the correct order
mid_grains = list(mid2colours.keys())
palette = list(mid2colours.values())
num_mid_grains = len(mid_grains)

# Step 3: Plot
plt.figure(figsize=(num_mid_grains * 0.4, 2))  # wide figure
sns.palplot(palette)
plt.xticks(np.arange(num_mid_grains), mid_grains, rotation=90)
plt.title("Mid Grain to Color Mapping")
plt.tight_layout()
plt.show()
```

Example 24 (python):
```python
/tmp/ipykernel_794362/455462603.py:18: UserWarning: Tight layout not applied. The bottom and top margins cannot be made large enough to accommodate all Axes decorations.
  plt.tight_layout()
```

Example 25 (unknown):
```unknown
<Figure size 448x160 with 0 Axes>
```

Example 26 (python):
```python
adata.obs['celltypist_mid_fin'] = pd.Categorical(
    adata.obs['celltypist_mid_fin'],
    categories=ad.obs[cat].cat.categories,
    ordered=True
)
```

Example 27 (python):
```python
latent_space = 'pca_harmony'
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color='celltypist_mid_fin',palette=palette,
                show=False
                   )
plt.savefig(f'{figdir}/Xenium5K_UMAP-midgrain_for-Fig1.pdf',bbox_inches="tight",dpi=300)
```

Example 28 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

sc.pl.spatial(slide,color=['celltypist_mid_fin'],
              spot_size=15,vmax='p100',
              # crop_coord=(4600,5600,4250,5250),
              show=False
             )
# plt.savefig(f'{figdir}/Xenium5K_euploid_SAN_for-Fig1.pdf',bbox_inches="tight",dpi=300)
```

Example 29 (python):
```python
/tmp/ipykernel_794362/1888614849.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['celltypist_mid_fin'],
```

Example 30 (unknown):
```unknown
[<Axes: title={'center': 'celltypist_mid_fin'}, xlabel='spatial1', ylabel='spatial2'>]
```

Example 31 (unknown):
```unknown
AnnotationPalette={ 
    'Atrium':'#eac075',
        'Ventricle - Compact':'#f1acfa',
     'Ventricle - Trabeculated':'#f09951',
        'SAnode':'#8A2BE2',
        'AVnode':'#062b4a',
    'VCS - Proximal':'#FFFF00',
        'VCS - Distal':'#7FFFD4',
        'Epicardium':'#01ccc8',
        'Endocardium - Atrial':'#DC143C',
        'Endocardium - Ventricular':'#f53527',
        'Endocardial cusion':'#ff7e97',
        'Great vessel':'#ff9b6e',
    'Ductus arteriosus':'#8a6800',
        'Coronary vessel':'#206601',
        'Adventitia - Coronary':'#CAFF70',
     'Adventitia - GV':'#005aa0',
        'AV ring':'#e478ff',
    'Valves':'#3300FF',
    'LN':'#9088ff',
}
```

Example 32 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]

sc.pl.spatial(slide,color=['tt_prediction'],
              spot_size=15,vmax='p100',
              # crop_coord=(4600,5600,4250,5250),
              show=False,
              palette=AnnotationPalette
             )
plt.savefig(f'{figdir}/TissueTypist_Xenium5K_whole-heart.pdf',bbox_inches="tight",dpi=300)
```

Example 33 (python):
```python
/tmp/ipykernel_968450/2063101229.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['tt_prediction'],
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/plotting/_utils.py:487: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns[value_to_plot + "_colors"] = colors_list
```

Example 34 (python):
```python
sc.pl.spatial(slide,color=['tt_prediction'],
              spot_size=15,vmax='p100',
              crop_coord=(5500,6800,4250,5500),
              show=False,
              palette=AnnotationPalette
             )
plt.savefig(f'{figdir}/TissueTypist_Xenium5K_Atrium-AVN.pdf',bbox_inches="tight",dpi=300)
```

Example 35 (python):
```python
/tmp/ipykernel_968450/2129560865.py:1: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['tt_prediction'],
```

Example 36 (python):
```python
sc.pl.spatial(slide,color=['tt_prediction'],
              spot_size=15,vmax='p100',
              crop_coord=(8000,9500,2500,4000),
              show=False,
              palette=AnnotationPalette
             )
plt.savefig(f'{figdir}/TissueTypist_Xenium5K_Ventricle.pdf',bbox_inches="tight",dpi=300)
```

Example 37 (python):
```python
/tmp/ipykernel_968450/2311424067.py:1: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['tt_prediction'],
```

Example 38 (python):
```python
sc.pl.spatial(slide,color=['tt_prediction'],
              spot_size=15,vmax='p100',
              crop_coord=(3500,5000,1800,3300),
              show=False,
              palette=AnnotationPalette
             )
plt.savefig(f'{figdir}/TissueTypist_Xenium5K_GV.pdf',bbox_inches="tight",dpi=300)
```

Example 39 (python):
```python
/tmp/ipykernel_968450/3875201264.py:1: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['tt_prediction'],
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/notebook_outs/no03-2_harmony_clustering_out_29May2025.html

**Contents:**
- Read in¶
- Clustering¶
- Save¶

**Examples:**

Example 1 (python):
```python
import scanpy as sc
import numpy as np
import pandas as pd
import os
# import rapids_singlecell as rsc
from tqdm import tqdm

import matplotlib.pyplot as plt
import seaborn as sns
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
tqdm                4.67.1
-----
```

Example 5 (python):
```python
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.45.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-05-29 12:14
```

Example 7 (python):
```python
sc.settings.set_figure_params(dpi=120)
```

Example 8 (python):
```python
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
adata
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_mid_fin_colors', 'pca', 'pca_harmony', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 10 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 11 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','tissue_block_id'], wspace=0.3, cmap='RdPu')
```

Example 12 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['celltypist_mid_fin'], wspace=0.2, cmap='RdPu')
```

Example 13 (python):
```python
%%time
latent_space='pca_harmony'
leiden_keys=[]
for res in tqdm([0.2,0.3,0.4,0.5,0.8,1.0,1.5,2.0,3.0]):
    leiden_key = f"leiden_{res}"
    key_added=f"{latent_space}_{leiden_key}"
    sc.tl.leiden(adata,neighbors_key=latent_space,resolution=res,key_added=key_added)
    leiden_keys.append(key_added)
```

Example 14 (unknown):
```unknown
0%|          | 0/9 [00:00<?, ?it/s]
```

Example 15 (unknown):
```unknown
<timed exec>:6: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 16 (unknown):
```unknown
11%|█         | 1/9 [07:39<1:01:13, 459.19s/it]
```

Example 17 (unknown):
```unknown
22%|██▏       | 2/9 [19:30<1:10:50, 607.25s/it]
```

Example 18 (unknown):
```unknown
33%|███▎      | 3/9 [33:44<1:12:01, 720.18s/it]
```

Example 19 (unknown):
```unknown
44%|████▍     | 4/9 [47:17<1:03:03, 756.76s/it]
```

Example 20 (unknown):
```unknown
56%|█████▌    | 5/9 [54:49<43:08, 647.04s/it]
```

Example 21 (unknown):
```unknown
67%|██████▋   | 6/9 [1:11:29<38:20, 766.86s/it]
```

Example 22 (unknown):
```unknown
78%|███████▊  | 7/9 [1:34:34<32:18, 969.11s/it]
```

Example 23 (unknown):
```unknown
89%|████████▉ | 8/9 [1:47:13<15:01, 901.98s/it]
```

Example 24 (unknown):
```unknown
100%|██████████| 9/9 [2:03:02<00:00, 916.69s/it]
```

Example 25 (unknown):
```unknown
100%|██████████| 9/9 [2:03:02<00:00, 820.25s/it]
```

Example 26 (unknown):
```unknown
CPU times: user 2h 2min 7s, sys: 46 s, total: 2h 2min 53s
Wall time: 2h 3min 2s
```

Example 27 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",
                color=leiden_keys,wspace=0.3,ncols=5)
```

Example 28 (python):
```python
adata.write(path_adata)
adata
```

Example 29 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_mid_fin_colors', 'pca', 'pca_harmony', 'tissue_block_id_colors', 'umap', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no01_C194-Hst45_concat.html

**Contents:**
- Read in¶
- Concatenate¶
- Update obs_names and save¶
- Save¶

**Examples:**

Example 1 (python):
```python
import scanpy as sc
import numpy as np
import pandas as pd
import os
# import rapids_singlecell as rsc
from tqdm import tqdm

import matplotlib.pyplot as plt
import seaborn as sns
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
tqdm                4.67.1
-----
```

Example 5 (python):
```python
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.45.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-05-29 11:15
```

Example 7 (python):
```python
sc.settings.set_figure_params(dpi=120)
```

Example 8 (unknown):
```unknown
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
```

Example 9 (python):
```python
sample_id_1 = 'C194-HEA-0-FFPE-1'
path_adata_1 = f'{objects_dir}/{sample_id_1}_5K_filtered_raw.h5ad'

sample_id_2 = 'Hst45-HEA-0-FFPE-1'
path_adata_2 = f'{objects_dir}/{sample_id_2}_5K_filtered_raw.h5ad'
```

Example 10 (python):
```python
adata_1 = sc.read_h5ad(path_adata_1)
adata_1
```

Example 11 (unknown):
```unknown
AnnData object with n_obs × n_vars = 144916 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts'
    obsm: 'spatial'
```

Example 12 (python):
```python
adata_2 = sc.read_h5ad(path_adata_2)
adata_2
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 217361 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts'
    obsm: 'spatial'
```

Example 14 (python):
```python
# tidy obs columns
adata_1.obs = adata_1.obs[['cell_id', 'x_centroid', 'y_centroid', 'transcript_counts',
       'control_probe_counts', 'genomic_control_counts',
       'control_codeword_counts', 'unassigned_codeword_counts',
       'deprecated_codeword_counts', 'total_counts', 'cell_area',
       'nucleus_area', 'nucleus_count', 'segmentation_method',
       'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts',
       'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes',
       'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts',
       'n_genes']]
adata_1.obs['tissue_block_id'] = sample_id_1

adata_2.obs = adata_2.obs[['cell_id', 'x_centroid', 'y_centroid', 'transcript_counts',
       'control_probe_counts', 'genomic_control_counts',
       'control_codeword_counts', 'unassigned_codeword_counts',
       'deprecated_codeword_counts', 'total_counts', 'cell_area',
       'nucleus_area', 'nucleus_count', 'segmentation_method',
       'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts',
       'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes',
       'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts',
       'n_genes']]
adata_2.obs['tissue_block_id'] = sample_id_2
```

Example 15 (python):
```python
# concatenate
adata = adata_1.concatenate(adata_2, 
            join='inner', 
            batch_key=None, 
            index_unique=None)
adata.obs['tissue_block_id'].value_counts()
```

Example 16 (python):
```python
/tmp/ipykernel_1481351/366024108.py:2: FutureWarning: Use anndata.concat instead of AnnData.concatenate, AnnData.concatenate is deprecated and will be removed in the future. See the tutorial for concat at: https://anndata.readthedocs.io/en/latest/concatenation.html
  adata = adata_1.concatenate(adata_2,
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1756: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.
  utils.warn_names_duplicates("obs")
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1756: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.
  utils.warn_names_duplicates("obs")
```

Example 17 (unknown):
```unknown
tissue_block_id
Hst45-HEA-0-FFPE-1    217361
C194-HEA-0-FFPE-1     144916
Name: count, dtype: int64
```

Example 18 (python):
```python
adata.obs_names = adata.obs['tissue_block_id'].astype('str') + '_' + adata.obs_names.astype('str')
adata.obs.head()
```

Example 19 (python):
```python
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
```

Example 20 (python):
```python
# save
adata.write(path_adata)
adata.obs.head()
```

Example 21 (python):
```python
adata.X.data[:5]
```

Example 22 (unknown):
```unknown
array([5., 1., 1., 2., 2.], dtype=float32)
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_myeloid.html

**Contents:**
- Variables¶
- Read in data¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 2 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-12 17:17
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'MyeloidCells'
```

Example 10 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 3965 × 4505
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([2.0822465, 2.0822465, 2.0822465, 2.0822465, 2.0822465],
      dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 2.62 s, sys: 71.3 ms, total: 2.69 s
Wall time: 2.7 s
```

Example 21 (python):
```python
markers={
    'Mono':['CCR2','FCN1','VCAN','MPO'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163','MERTK'],
    'CX3CR1+':['CX3CR1','C3','TREM2','P2RY12'],
    'LYVE1+':['LYVE1','FOLR2'],
     'pDC':['IRF8','IRF4','IL3RA'],
     'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'Megakaryocyte':['ITGA2B','MPL','ITGB3',],
    'Mast': ['KIT', 'CPA3','HDC','GATA2'],
    'Cycling':['MKI67','TOP2A'],
}
genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 22 (unknown):
```unknown
resolution_sel = 1.5
```

Example 23 (python):
```python
markers={
    'Mono':['CCR2','FCN1','VCAN','MPO'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163','MERTK'],
    'CX3CR1+':['CX3CR1','C3','TREM2','P2RY12'],
    'LYVE1+':['LYVE1','FOLR2'],
     'pDC':['IRF8','IRF4','IL3RA'],
     'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'Megakaryocyte':['ITGA2B','MPL','ITGB3',],
    'Mast': ['KIT', 'CPA3','HDC','GATA2'],
    'Cycling':['MKI67','TOP2A'],
}
for k,g in markers.items():
    markers[k] = [x for x in g if x in adata.var_names]

sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 24 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: Mono, MP, CX3CR1+, etc.
```

Example 25 (python):
```python
markers = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 26 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 27 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 28 (unknown):
```unknown
[2.0822465 2.0822465 2.0822465 2.0822465 2.0822465]
```

Example 29 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 30 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 31 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'Macrophages',
    '1':'Macrophages',
    '2':'unassigned',
    '3':'Macrophages',
    '4':'Macrophages',
    '5':'Macrophages',
    '6':'Erythrocytes',
    '7':'Macrophages',
    '8':'Monocytes',
    '9':'Macrophages',
    '10':'MastCells',
    '11':'Macrophages',
    '12':'MyeloidCells_Doublets',
    '13':'ErythrocytesCycling',
    '14':'Macrophages',
    '15':'Megakaryocytes',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 32 (python):
```python
/tmp/ipykernel_285284/3101446981.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 33 (unknown):
```unknown
tmp_annotation
Macrophages              2727
unassigned                522
Erythrocytes              231
Monocytes                 220
MastCells                  91
MyeloidCells_Doublets      67
ErythrocytesCycling        65
Megakaryocytes             42
Name: count, dtype: int64
```

Example 34 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 35 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['Monocytes','Macrophages'])]
```

Example 36 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 37 (unknown):
```unknown
AnnData object with n_obs × n_vars = 2947 × 4505
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1.5', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 38 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 39 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 2947 × 4059
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1.5', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 40 (python):
```python
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
```

Example 41 (unknown):
```unknown
(2947, 4006)
```

Example 42 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 43 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 44 (unknown):
```unknown
number of hvgs: 742
```

Example 45 (python):
```python
2025-06-12 17:24:35,549 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-12 17:24:37,152 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-12 17:24:37,207 - harmonypy - INFO - Iteration 1 of 10
2025-06-12 17:24:37,480 - harmonypy - INFO - Iteration 2 of 10
2025-06-12 17:24:37,754 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 46 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 47 (unknown):
```unknown
CPU times: user 4.19 s, sys: 134 ms, total: 4.32 s
Wall time: 4.34 s
```

Example 48 (python):
```python
markers={
    'Mono':['CCR2','FCN1','VCAN','MPO'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163','MERTK'],
    'CX3CR1+':['CX3CR1','C3','TREM2','P2RY12'],
    'LYVE1+':['LYVE1','FOLR2'],
     'pDC':['IRF8','IRF4','IL3RA'],
     'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'Cycling':['MKI67','TOP2A'],
}
genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 49 (unknown):
```unknown
sub_resolution_sel = 1
```

Example 50 (python):
```python
markers={
    'Mono':['CCR2','FCN1','VCAN','MPO'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163','MERTK'],
    'CX3CR1+':['CX3CR1','C3','TREM2','P2RY12'],
    'LYVE1+':['LYVE1','FOLR2'],
     'pDC':['IRF8','IRF4','IL3RA'],
     'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'Cycling':['MKI67','TOP2A'],
}
for k,g in markers.items():
    markers[k] = [x for x in g if x in adata_sub.var_names]

sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 51 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: Mono, MP, CX3CR1+, etc.
```

Example 52 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 53 (unknown):
```unknown
[2.0822465 2.0822465 2.0822465 2.0822465 2.0822465]
```

Example 54 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}', legend_loc='on data',
                wspace=0.3)
```

Example 55 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'MacrophagesLYVE1pos',
    '1':'MacrophagesCX3CR1pos',
    '2':'unassigned',
    '3':'MacrophagesLYVE1pos',
    '4':'Monocytes',
    '5':'Monocytes',
    '6':'MacrophagesCX3CR1pos',
     '7':'MacrophagesCX3CR1pos',
     '8':'DendriticCells',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 56 (python):
```python
/tmp/ipykernel_285284/1602106113.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 57 (unknown):
```unknown
fine_grain_manual
MacrophagesLYVE1pos     993
MacrophagesCX3CR1pos    910
unassigned              551
Monocytes               467
DendriticCells           26
Name: count, dtype: int64
```

Example 58 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 59 (python):
```python
markers={
    'Mono':['CCR2','FCN1','VCAN','MPO'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163','MERTK'],
    'CX3CR1+':['CX3CR1','C3','TREM2','P2RY12'],
    'LYVE1+':['LYVE1','FOLR2'],
     'pDC':['IRF8','IRF4','IL3RA'],
     'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'Cycling':['MKI67','TOP2A'],
}
for k,g in markers.items():
    markers[k] = [x for x in g if x in adata_sub.var_names]

sc.tl.dendrogram(adata_sub,groupby='fine_grain_manual')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 60 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: MacrophagesLYVE1pos, MacrophagesCX3CR1pos, unassigned, etc.
var_group_labels: Mono, MP, CX3CR1+, etc.
```

Example 61 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 62 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 63 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
                  spot_size=60,vmax='p100')
```

Example 64 (python):
```python
/tmp/ipykernel_285284/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 65 (python):
```python
/tmp/ipykernel_285284/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 66 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],groups='MacrophagesCX3CR1pos',
                  spot_size=80,vmax='p100')
```

Example 67 (python):
```python
/tmp/ipykernel_285284/642200447.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='MacrophagesCX3CR1pos',
```

Example 68 (python):
```python
/tmp/ipykernel_285284/642200447.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='MacrophagesCX3CR1pos',
```

Example 69 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],groups='MacrophagesLYVE1pos',
                  spot_size=60,vmax='p100')
```

Example 70 (python):
```python
/tmp/ipykernel_285284/895811050.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='MacrophagesLYVE1pos',
```

Example 71 (python):
```python
/tmp/ipykernel_285284/895811050.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='MacrophagesLYVE1pos',
```

Example 72 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],groups='DendriticCells',
                  spot_size=80,vmax='p100')
```

Example 73 (python):
```python
/tmp/ipykernel_285284/2965593451.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='DendriticCells',
```

Example 74 (python):
```python
/tmp/ipykernel_285284/2965593451.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='DendriticCells',
```

Example 75 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 76 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_MyeloidCells_lognorm.h5ad
```

Example 77 (python):
```python
sc.tl.dendrogram(adata,groupby='fine_grain_manual')
sc.pl.dotplot(adata,
              var_names=['P2RY12','CX3CR1','TREM2','SIRPA'],
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/No3_global_UMAP-clustering.html

**Contents:**
- Import modules¶
- Read in data¶
- Clustering, UMAP, check modalities, QCs¶
- Proportions¶
- Reconstruct raw counts¶
- Save¶

**Examples:**

Example 1 (python):
```python
import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import anndata
import matplotlib.pyplot as plt
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
-----
anndata             0.7.5
matplotlib          3.3.4
numpy               1.20.1
pandas              1.1.4
scanpy              1.7.1
session_info        1.0.0
-----
```

Example 4 (unknown):
```unknown
PIL                 8.1.2
anyio               NA
attr                20.3.0
babel               2.9.0
backcall            0.2.0
brotli              NA
cairo               1.20.0
certifi             2020.12.05
cffi                1.14.5
chardet             4.0.0
cloudpickle         1.6.0
colorama            0.4.4
cycler              0.10.0
cython_runtime      NA
cytoolz             0.11.0
dask                2021.03.1
dateutil            2.8.1
decorator           4.4.2
fsspec              0.8.7
get_version         2.1
google              NA
h5py                2.10.0
idna                2.10
igraph              0.8.3
ipykernel           5.5.0
ipython_genutils    0.2.0
jedi                0.18.0
jinja2              2.11.3
joblib              1.0.1
json5               NA
jsonschema          3.2.0
jupyter_server      1.4.1
jupyterlab_server   2.3.0
kiwisolver          1.3.1
legacy_api_wrap     0.0.0
leidenalg           0.8.3
llvmlite            0.34.0
louvain             0.7.0
markupsafe          1.1.1
mpl_toolkits        NA
natsort             7.1.1
nbclassic           NA
nbformat            5.1.2
numba               0.51.2
numexpr             2.7.3
packaging           20.9
parso               0.8.1
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
prometheus_client   NA
prompt_toolkit      3.0.16
psutil              5.8.0
ptyprocess          0.7.0
pvectorc            NA
pyarrow             0.16.0
pygments            2.8.0
pyparsing           2.4.7
pyrsistent          NA
pytoml              NA
pytz                2021.1
requests            2.25.1
ruamel              NA
scipy               1.6.1
send2trash          NA
setuptools_scm      NA
simplejson          3.17.2
sinfo               0.3.1
six                 1.15.0
sklearn             0.22
sniffio             1.2.0
socks               1.7.1
sphinxcontrib       NA
storemagic          NA
tables              3.6.1
tblib               1.7.0
texttable           1.6.3
tlz                 0.11.0
toolz               0.11.1
tornado             6.1
traitlets           5.0.5
typing_extensions   NA
uritemplate         3.0.1
urllib3             1.26.3
wcwidth             0.2.5
yaml                5.1.2
zmq                 22.0.3
```

Example 5 (unknown):
```unknown
-----
IPython             7.21.0
jupyter_client      6.1.11
jupyter_core        4.7.1
jupyterlab          3.0.9
notebook            6.2.0
-----
Python 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:22:27) [GCC 9.3.0]
Linux-4.15.0-112-generic-x86_64-with-glibc2.10
-----
Session information updated at 2023-02-16 10:29
```

Example 6 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=200, color_map = 'RdPu',)
```

Example 7 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/scVI/RNA_foetal_scVI.h5ad')
adata
```

Example 8 (unknown):
```unknown
AnnData object with n_obs × n_vars = 372801 × 3343
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: '_scvi', 'hvg'
    obsm: 'X_scVI', '_scvi_extra_continuous', 'latent_gene_encoding'
    layers: 'counts'
```

Example 9 (unknown):
```unknown
genename_column='gene_name_multiome-1'
```

Example 10 (python):
```python
# add previous annotation
prev=sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/2JanCell2locObjectRaw.h5ad',backed='r')

adata.obs['2Jan_coarse_grain'] = prev.obs['coarse_grain'].reindex(adata.obs_names)
adata.obs['2Jan_mid_grain'] = prev.obs['mid_grain'].reindex(adata.obs_names)
adata.obs['2Jan_fine_grain'] = prev.obs['fine_grain'].reindex(adata.obs_names)
```

Example 11 (python):
```python
pd.crosstab(adata.obs['donor'],adata.obs['age'])
```

Example 12 (python):
```python
%%time
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata, min_dist=0.2)
sc.tl.leiden(adata, resolution=1, key_added='leiden_scVI',)
```

Example 13 (python):
```python
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:01:10)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:07:45)
running Leiden clustering
    finished: found 48 clusters and added
    'leiden_scVI', the cluster labels (adata.obs, categorical) (0:06:27)
```

Example 14 (unknown):
```unknown
CPU times: user 35min 35s, sys: 10min 35s, total: 46min 11s
Wall time: 15min 23s
```

Example 15 (python):
```python
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=['leiden_scVI','2Jan_mid_grain'], size=2, wspace=0.1, legend_loc='on data', legend_fontsize=5)
```

Example 16 (python):
```python
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=['cell_or_nuclei','kit_10x','donor'], size=2, wspace=0.1, legend_loc='on data', legend_fontsize=5)
```

Example 17 (python):
```python
sc.pl.umap(adata, color=['2Jan_fine_grain'], size=2, wspace=0.1, legend_loc='on data', legend_fontsize=3)
```

Example 18 (python):
```python
sc.pl.umap(adata, color=['age'], size=1, legend_fontsize=7)
```

Example 19 (python):
```python
sc.pl.umap(adata, color=['region'], size=1, legend_fontsize=7)
```

Example 20 (python):
```python
sc.pl.umap(adata, color=['multiplexed'], groups='Yes', size=1, legend_fontsize=7)
```

Example 21 (python):
```python
sc.pl.umap(adata, color=['SOC | status'], groups='doublet', size=1, legend_fontsize=7)
```

Example 22 (python):
```python
sc.pl.umap(adata, color=['region'], groups=['Pericardium','Aorta','Left ventricle','Pulmonary artery + main bronchus'], size=2, legend_loc='on data', legend_fontsize=5)
```

Example 23 (python):
```python
sc.pl.umap(adata, color=['age'], groups=['PCW-12w','PCW-13w','PCW-14w','PCW-15w','PCW-20w'], size=2, legend_loc='on data', legend_fontsize=5, ncols=5)
```

Example 24 (python):
```python
sc.pl.umap(adata, color=['donor','cell_or_nuclei','kit_10x','facility'], size=0.5, wspace=0.6)
```

Example 25 (python):
```python
sc.settings.set_figure_params(dpi=200, color_map = 'RdPu',)
sc.pl.umap(adata, color=['n_genes', 'n_genes_by_counts',
       'total_counts','pct_counts_mt','pct_counts_ribo'], size=2, wspace=0.2, ncols=5)
```

Example 26 (python):
```python
sc.pl.umap(adata, color=['scrublet_score','cluster_scrublet_score','doublet_pval','doublet_bh_pval'], size=2, wspace=0.2, ncols=5)
```

Example 27 (python):
```python
plt.rcParams['figure.figsize'] = 5,5
tmp = pd.crosstab(adata.obs['kit_10x'], adata.obs['age'], normalize='index')
# tmp.plot.bar().legend(loc=1)
ax = tmp.plot.bar(stacked=True,width=0.7)
ax.grid(False)
ax.set_ylabel('proportion')
ax.legend(bbox_to_anchor=(1.0, 1.0))
ax.plot()
```

Example 28 (python):
```python
adata_raw=sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/RNA_foetal_raw.h5ad')
print(adata_raw)

adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated data
                      obsp=adata.obsp # from annotated data
                               )
print(adata_raw)
```

Example 29 (unknown):
```unknown
AnnData object with n_obs × n_vars = 372801 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1'
    obsm: 'latent_gene_encoding'
AnnData object with n_obs × n_vars = 372801 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1'
    obsm: 'X_scVI', '_scvi_extra_continuous', 'latent_gene_encoding', 'X_umap'
    obsp: 'distances', 'connectivities'
```

Example 30 (python):
```python
### add CD45 sorting key ###
cd45 = pd.read_csv('/nfs/team205/heart/anndata_objects/Foetal/metadata/5prime_FACS.csv')
cd45.rename(columns={'FACS gate':'FACSgate'},inplace=True)
print(cd45)

adata_raw.obs = adata_raw.obs.reset_index().merge(cd45,how='left',on='sangerID').set_index('barcode')
adata_raw.obs[['FACSgate','sangerID']].value_counts()
```

Example 31 (unknown):
```unknown
sangerID FACSgate
0  BHF_F_Hea10402917  CD45pos
1  BHF_F_Hea10402918  CD45neg
2  BHF_F_Hea11192323  CD45pos
3  BHF_F_Hea11192324  CD45neg
4  BHF_F_Hea11192325  CD45pos
5  BHF_F_Hea11192326  CD45neg
6  BHF_F_Hea11192327  CD45pos
7  BHF_F_Hea11192328  CD45neg
```

Example 32 (unknown):
```unknown
FACSgate  sangerID         
CD45neg   BHF_F_Hea11192328    12056
          BHF_F_Hea11192324    10553
          BHF_F_Hea11192326     9876
CD45pos   BHF_F_Hea11192325     7512
          BHF_F_Hea11192327     5865
CD45neg   BHF_F_Hea10402918     4340
CD45pos   BHF_F_Hea11192323     3418
          BHF_F_Hea10402917     2227
dtype: int64
```

Example 33 (python):
```python
adata_raw.obs['FACSgate'].unique()
```

Example 34 (unknown):
```unknown
array(['CD45pos', 'CD45neg', nan], dtype=object)
```

Example 35 (python):
```python
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/RNA_foetal_post-scVI_raw.h5ad')
adata_raw
```

Example 36 (unknown):
```unknown
... storing 'sangerID' as categorical
... storing 'FACSgate' as categorical
```

Example 37 (unknown):
```unknown
AnnData object with n_obs × n_vars = 372801 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1'
    obsm: 'X_scVI', '_scvi_extra_continuous', 'latent_gene_encoding', 'X_umap'
    obsp: 'distances', 'connectivities'
```

Example 38 (python):
```python
adata_raw=sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/RNA_foetal_post-scVI_raw.h5ad')
adata_raw
```

Example 39 (unknown):
```unknown
AnnData object with n_obs × n_vars = 372801 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_continuous', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 40 (python):
```python
adata_raw[adata_raw.obs['2Jan_coarse_grain']=='Leukocytes'].obs['age'].value_counts()
```

Example 41 (unknown):
```unknown
PCW-20w     21354
GA-10w4d     5353
GA-9w4d      3025
11w3d        1987
PCW-13w      1728
GA-12w5d     1627
9w6d          890
9w3d          604
8w5d          520
GA-7w4d       482
8w2d          398
9w1d          376
GA-9w         359
GA-11w2d      101
GA-11w3d       62
GA-6w3d        40
Name: age, dtype: int64
```

Example 42 (python):
```python
adata_raw.obs['2Jan_coarse_grain'].value_counts()
```

Example 43 (unknown):
```unknown
Mesenchymal       128528
Cardiomyocytes     96591
Leukocytes         38906
Endothelium        20122
Neural              5998
Epicardium          3879
Name: 2Jan_coarse_grain, dtype: int64
```

Example 44 (python):
```python
set(adata_raw.obs['cell_or_nuclei'])
```

Example 45 (unknown):
```unknown
{'Cell', 'Nuclei'}
```

Example 46 (python):
```python
import sys
sys.getsizeof(adata_raw)
```

Example 47 (unknown):
```unknown
# rclone to gdrive
rclone copy /nfs/team205/heart/anndata_objects/Foetal/RNA_foetal_post-scVI_raw.h5ad \
gdrive:JamesC_Kazumasa/Foetal_Heart/SanjayShinha/toSinhalab/anndata/
```

Example 48 (python):
```python
adata_raw.obs['region'].value_counts()
```

Example 49 (python):
```python
sc.pl.umap(adata_raw, color=['region'], groups=['Pericardium','Aorta','Left ventricle','Pulmonary artery  + main bronchus'], size=2,legend_fontsize=7)
```

Example 50 (python):
```python
sc.pl.umap(adata_raw, color=['region'], groups=['Pericardium'], size=2,legend_fontsize=7)
```

Example 51 (python):
```python
sc.pl.umap(adata_raw[adata_raw.obs['region']!='Pulmonary artery  + main bronchus'], 
           color=['previous_mid_grain'], size=2,legend_fontsize=7)
```

Example 52 (python):
```python
adata_raw[adata_raw.obs['age']=='PCW-20w']
```

Example 53 (python):
```python
ad = adata_raw[adata_raw.obs['age']=='PCW-20w']

plt.rcParams['figure.figsize'] = 5,5
tmp = pd.crosstab(ad.obs['previous_mid_grain'], ad.obs['region'], normalize='index')
# tmp.plot.bar().legend(loc=1)
ax = tmp.plot.bar(stacked=True,width=0.7)
ax.grid(False)
ax.set_ylabel('proportion')
ax.legend(bbox_to_anchor=(1.0, 1.0))
ax.plot()
```

Example 54 (python):
```python
# filter and lognormalised
sc.pp.filter_genes(adata_raw, min_cells=3)
sc.pp.normalize_total(adata_raw, target_sum=1e4)
sc.pp.log1p(adata_raw)
```

Example 55 (python):
```python
# set gene name as var_names 
adata_raw.var['gene_id']=adata_raw.var_names.copy()
adata_raw.var.set_index('gene_name_multiome-1',inplace=True)
adata_raw.var_names=adata_raw.var_names.astype('str')
adata_raw.var_names_make_unique()
```

Example 56 (python):
```python
sc.pl.umap(adata_raw, 
           color=['FOXP3','CD4','CD8A','CD3E'], size=2,legend_fontsize=7)
```

Example 57 (python):
```python
for reg in set(adata_raw.obs['region']):
    print(reg)
    sc.pl.umap(adata_raw[adata_raw.obs['region']==reg], 
           color=['FOXP3','CD4','CD8A','CD3E'], size=2,legend_fontsize=7)
```

Example 58 (python):
```python
set(adata_raw.obs['region'])
```

Example 59 (python):
```python
pd.crosstab(ad.obs['previous_mid_grain'], ad.obs['region'], normalize='index')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Visium/Visium_Intagration-Annotation/Visium_integration_no3_annotation.html

**Contents:**
- Functions¶
- Cell types for supporting annotation¶
- Read in anndata¶
- Annotate¶
- Subset and re-integration - Myocardium¶
- Subset and re-integration - CCS, Valve cells¶
- Subset and re-integration - Atrium¶
- Subset and re-integration - Vessels¶
- Subset and re-integration - Node cells¶
- Annotate based on cell2location estimated abundance¶
- Collect all annotations so far¶
- Refine annotations (with using manual annotations)¶
  - Fully dependent on manual annotation¶
  - Partly dependent on manual annotation¶
  - Coronary vessel vs Great vessel¶
  - Myocardium Atrial¶
  - Myocardium Ventricular - Compact¶
  - Myocardium Ventricular - Trabeculated¶
- Add to anndata¶
- Save¶

39223 rows × 7 columns

if "pre-final" is 'tbd -' or 'Uncertain', then use manual annotation

Overwrite "coronary vessel" spots ("pre-final") which were manualy annotated as "Great vessels"

**Examples:**

Example 1 (python):
```python
import sys
import scanpy as sc
import anndata
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt 
import matplotlib as mpl

from matplotlib import rcParams
rcParams['pdf.fonttype'] = 42 # enables correct plotting of text
import seaborn as sns

import os

import bbknn
```

Example 2 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 3 (python):
```python
# This function selects the data for multiple slides from the spatial anndata object.
# Modified `select_slide` in cell2loc for multiple slides

# @param adata: anndata object with multiple spatial experiments
# @param s: list of selected slides
# @param s_col: column in adata.obs listing experiment name for each location

def select_multislide(adata, s, s_col='sample'):

    slides = adata[adata.obs[s_col].isin(s), :]
    s_keys = list(slides.uns['spatial'].keys())
    
    uns_dict = {}
    for ss in s:
        s_spatial=np.array(s_keys)[[ss in k for k in s_keys]][0]
        uns_dict[s_spatial]=slides.uns['spatial'][s_spatial]
    
    slides.uns['spatial'] = uns_dict

    return slides
```

Example 4 (unknown):
```unknown
celltypes_for_annotation = {
    'Atrium':['AtrialCardiomyocytesLeft','AtrialCardiomyocytesRight'],
    'Ventricle':['VentricularCardiomyocytesLeftCompact',
                 'VentricularCardiomyocytesRightCompact',
                 'VentricularCardiomyocytesLeftTrabeculated',
                 'VentricularCardiomyocytesRightTrabeculated'],
    'CCS':['SinoatrialNodeCardiomyocytes',
             'AtrioventricularNodeCardiomyocytes',
             'VentricularConductionSystemProximal',
             'VentricularConductionSystemDistal',],
    'Adventitia':['GreatVesselAdventitialFibroblasts','CoronaryVesselAdventitialFibroblasts'],
    'LN':['LymphNodeFibroblasticReticularCells'],
    'Valve':['ValveInterstitialCells'],
    'Endocardium':['EndocardialCells','EndocardialCushionCells'],
    'Epicardium':['MesothelialEpicardialCells','EpicardiumDerivedCells'],
    'DuctusArteriosus':['DuctusArteriosusSmoothMuscleCells']
}
```

Example 5 (python):
```python
# the anndata has "gene expression" in .X
# cell2location output is in .obsm['q05_cell_abundance_w_sf']
# kNN graph for UMAP/clustering was generated using cell2location output
adata_vis = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_raw.h5ad')
adata_vis
```

Example 6 (unknown):
```unknown
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 7 (unknown):
```unknown
AnnData object with n_obs × n_vars = 39223 × 33562
    obs: 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'cell2loc-map_group', 'JC_edit', 'sample_for_cell2loc', 'week', 'leiden', 'region_cluster', 'AtrialCardiomyocytesLeft', 'AtrialCardiomyocytesRight', 'VentricularCardiomyocytesLeftCompact', 'VentricularCardiomyocytesRightCompact', 'VentricularCardiomyocytesLeftTrabeculated', 'VentricularCardiomyocytesRightTrabeculated', 'SinoatrialNodeCardiomyocytes', 'AtrioventricularNodeCardiomyocytes', 'VentricularConductionSystemProximal', 'VentricularConductionSystemDistal', 'GreatVesselAdventitialFibroblasts', 'CoronaryVesselAdventitialFibroblasts', 'MyocardialInterstitialFibroblasts1', 'MyocardialInterstitialFibroblasts2', 'Myofibroblasts', 'LymphNodeFibroblasticReticularCells', 'ValveInterstitialCells', 'GreatVesselSmoothMuscleCells', 'CoronarySmoothMuscleCells', 'CoronaryPericytes', 'GreatVesselArterialEndothelialCells', 'GreatVesselVenousEndothelialCells', 'CoronaryArterialEndothelialCells', 'CoronaryVenousEndothelialCells', 'CoronaryCapillaryEndothelialCells', 'EndocardialCells', 'EndocardialCushionCells', 'ValveEndothelialCells', 'LymphaticEndothelialCells', 'MesothelialEpicardialCells', 'EpicardiumDerivedCells', 'NeuronPrecursors', 'ChromaffinCells', 'SympatheticNeurons', 'ParaympatheticNeurons', 'SchwannCellPrecursors', 'SchwannCells', 'MonocytesMPOpos', 'Monocytes', 'MonocyteDerivedCells', 'MacrophagesCX3CR1pos', 'MacrophagesTIMD4pos', 'MacrophagesLYVE1pos', 'MacrophagesATF3pos', 'DendriticCellsType1', 'DendriticCellsMature', 'PlasmacytoidDendriticCells', 'MastCells', 'Megakaryocytes', 'TCellsCD4pos', 'TCellsCD8pos', 'TregsCD4pos', 'ProBCells', 'BCells', 'BCellsMS4A1pos', 'NaturalKillerCells', 'InnateLymphoidCells', 'DuctusArteriosusSmoothMuscleCells', 'AtrialCardiomyocytesLeft_minmax', 'AtrialCardiomyocytesRight_minmax', 'VentricularCardiomyocytesLeftCompact_minmax', 'VentricularCardiomyocytesRightCompact_minmax', 'VentricularCardiomyocytesLeftTrabeculated_minmax', 'VentricularCardiomyocytesRightTrabeculated_minmax', 'SinoatrialNodeCardiomyocytes_minmax', 'AtrioventricularNodeCardiomyocytes_minmax', 'VentricularConductionSystemProximal_minmax', 'VentricularConductionSystemDistal_minmax', 'GreatVesselAdventitialFibroblasts_minmax', 'CoronaryVesselAdventitialFibroblasts_minmax', 'MyocardialInterstitialFibroblasts1_minmax', 'MyocardialInterstitialFibroblasts2_minmax', 'Myofibroblasts_minmax', 'LymphNodeFibroblasticReticularCells_minmax', 'ValveInterstitialCells_minmax', 'GreatVesselSmoothMuscleCells_minmax', 'CoronarySmoothMuscleCells_minmax', 'CoronaryPericytes_minmax', 'GreatVesselArterialEndothelialCells_minmax', 'GreatVesselVenousEndothelialCells_minmax', 'CoronaryArterialEndothelialCells_minmax', 'CoronaryVenousEndothelialCells_minmax', 'CoronaryCapillaryEndothelialCells_minmax', 'EndocardialCells_minmax', 'EndocardialCushionCells_minmax', 'ValveEndothelialCells_minmax', 'LymphaticEndothelialCells_minmax', 'MesothelialEpicardialCells_minmax', 'EpicardiumDerivedCells_minmax', 'NeuronPrecursors_minmax', 'ChromaffinCells_minmax', 'SympatheticNeurons_minmax', 'ParaympatheticNeurons_minmax', 'SchwannCellPrecursors_minmax', 'SchwannCells_minmax', 'MonocytesMPOpos_minmax', 'Monocytes_minmax', 'MonocyteDerivedCells_minmax', 'MacrophagesCX3CR1pos_minmax', 'MacrophagesTIMD4pos_minmax', 'MacrophagesLYVE1pos_minmax', 'MacrophagesATF3pos_minmax', 'DendriticCellsType1_minmax', 'DendriticCellsMature_minmax', 'PlasmacytoidDendriticCells_minmax', 'MastCells_minmax', 'Megakaryocytes_minmax', 'TCellsCD4pos_minmax', 'TCellsCD8pos_minmax', 'TregsCD4pos_minmax', 'ProBCells_minmax', 'BCells_minmax', 'BCellsMS4A1pos_minmax', 'NaturalKillerCells_minmax', 'InnateLymphoidCells_minmax', 'DuctusArteriosusSmoothMuscleCells_minmax', 'annotation', 'annotation_final'
    var: 'gene_ids'
    uns: 'JC_edit_colors', 'annotation_colors', 'annotation_final_colors', 'cell2loc-map_group_colors', 'leiden', 'neighbors', 'region_cluster_colors', 'sample_for_cell2loc_colors', 'umap'
    obsm: 'MT', 'X_umap', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q05_cell_abundance_w_sf_ndarray', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
    obsp: 'connectivities', 'distances'
```

Example 8 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['region_cluster'], size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False, legend_loc='on data')
```

Example 9 (python):
```python
# add cell2loc out to .obs
cellnames = adata_vis.obsm['q05_cell_abundance_w_sf'].columns
cellnames = [x.split('q05cell_abundance_w_sf_')[1] for x in cellnames]
adata_vis.obs[cellnames] = adata_vis.obsm['q05_cell_abundance_w_sf'].copy()

# add normalise cell2loc output: min-max
df = adata_vis.obsm['q05_cell_abundance_w_sf'].copy()
df = (df-df.min())/(df.max()-df.min())
adata_vis.obs[[f'{x}_minmax' for x in cellnames]] = df.copy()
```

Example 10 (python):
```python
for structure,celltypes in celltypes_for_annotation.items():
    print(f'##### {structure} #####')
    with mpl.rc_context({'axes.facecolor':  'white',
                         'figure.figsize': [4, 4]}):
        sc.pl.umap(adata_vis, color=[f'{x}_minmax' for x in celltypes], size=20,
                   color_map = 'RdPu', ncols = 4, wspace=0.3, vmax='p99.98',
                   legend_fontsize=14, frameon=False)
```

Example 11 (unknown):
```unknown
##### Atrium #####
```

Example 12 (unknown):
```unknown
##### Ventricle #####
```

Example 13 (unknown):
```unknown
##### CCS #####
```

Example 14 (unknown):
```unknown
##### Adventitia #####
```

Example 15 (unknown):
```unknown
##### LN #####
```

Example 16 (unknown):
```unknown
##### Valve #####
```

Example 17 (unknown):
```unknown
##### Endocardium #####
```

Example 18 (unknown):
```unknown
##### Epicardium #####
```

Example 19 (unknown):
```unknown
##### DuctusArteriosus #####
```

Example 20 (python):
```python
adata_vis.obs['annotation'] = adata_vis.obs['region_cluster']
adata_vis.obs['annotation'] = adata_vis.obs['annotation'].astype('str')
adata_vis.obs.replace({'annotation': {
    '0': 'Ventricle', 
    '1': 'Ventricle', 
    '2': 'Ventricle', 
    '3': 'Ventricle', 
    '4': 'Ventricle', 
    '5': 'Ventricle', 
    '6': 'Ventricle', 
    '7': 'Ventricle', 
    '8': 'Ventricle', 
    '9': 'Atrium', 
    '10': 'AV ring - Valves', 
    '11': 'Ventricle', 
    '12': 'Vessels', 
    '13': 'Atrium', 
    '14': 'Ventricle', 
    '15': 'Atrium', 
    '16': 'Vessels', 
    '17': 'Vessels', 
    '18': 'Ventricle', 
    '19': 'Ventricle',   
    '20': 'Vessels', 
    '21': 'Vessels', 
    '22': 'Vessels', 
    '23': 'Vessels', 
}}, inplace=True)
```

Example 21 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['annotation'], size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False, legend_loc='on data')
```

Example 22 (python):
```python
set(adata_vis.obs['annotation'])
```

Example 23 (unknown):
```unknown
{'AV ring - Valves', 'Atrium', 'Ventricle', 'Vessels'}
```

Example 24 (python):
```python
# save annotations
annot_df = adata_vis.obs[['annotation']].copy()
annot_df.rename(columns={'annotation':'global_annotation'},inplace=True)
annot_df.head()
```

Example 25 (unknown):
```unknown
structures = ['AV ring - Valves','Atrium','Ventricle']
```

Example 26 (python):
```python
# subset
adata_sub = adata_vis[adata_vis.obs['annotation'].isin(structures)]

# # compute KNN using the cell2location output stored in adata.obsm
# bbknn
bbknn.bbknn(adata_sub, batch_key='sample_for_cell2loc', use_rep='q05_cell_abundance_w_sf_ndarray')

# Cluster spots into regions using scanpy
sc.tl.leiden(adata_sub, resolution=2)

# add region as categorical variable
adata_sub.obs["region_cluster"] = adata_sub.obs["leiden"].astype("category")

# compute UMAP using KNN graph based on the cell2location output
sc.tl.umap(adata_sub, min_dist = 0.2, spread = 1)  # n_components=3
```

Example 27 (unknown):
```unknown
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/compat/_overloaded_dict.py:179: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  ovld.data[key] = neighbors
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 28 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_sub, color=['week','JC_edit'], size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,
               legend_fontsize=14, frameon=False, components='all')
```

Example 29 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_sub, color=['JC_edit'], groups='AVN',size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 30 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 31 (python):
```python
for structure,celltypes in celltypes_for_annotation.items():
    print(f'##### {structure} #####')
    with mpl.rc_context({'axes.facecolor':  'white',
                         'figure.figsize': [4, 4]}):
        sc.pl.umap(adata_sub, color=[f'{x}_minmax' for x in celltypes], size=10,
                   color_map = 'RdPu', ncols = 4, wspace=0.1, vmax='p99.98',
                   legend_fontsize=14, frameon=False)
```

Example 32 (unknown):
```unknown
##### Atrium #####
```

Example 33 (unknown):
```unknown
##### Ventricle #####
```

Example 34 (unknown):
```unknown
##### CCS #####
```

Example 35 (unknown):
```unknown
##### Adventitia #####
```

Example 36 (unknown):
```unknown
##### LN #####
```

Example 37 (unknown):
```unknown
##### Valve #####
```

Example 38 (unknown):
```unknown
##### Endocardium #####
```

Example 39 (unknown):
```unknown
##### Epicardium #####
```

Example 40 (unknown):
```unknown
##### DuctusArteriosus #####
```

Example 41 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], groups=['11','14','21'],size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 42 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='region_cluster',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 43 (python):
```python
adata_sub.obs['annotation'] = adata_sub.obs['region_cluster']
adata_sub.obs['annotation'] = adata_sub.obs['annotation'].astype('str')
adata_sub.obs.replace({'annotation': {
    '0': 'Ventricle - Compact - Right', 
    '1': 'tbd - Atrium - Left', 
    '2': 'Ventricle - Compact - Left', 
    '3': 'Ventricle - Compact - Left', 
    '4': 'Ventricle - Trabeculated - Right', 
    '5': 'Ventricle - Compact - Right',  
    '6': 'Ventricle - Trabeculated - Left', 
    '7': 'Ventricle - Compact - Left',  
    '8': 'Ventricle - Compact - Left',  
    '9': 'tbd - CCS, Valves', 
    '10': 'Ventricle - Trabeculated - Left', 
    '11': 'tbd - Ventricle', 
    '12': 'tbd - Atrium - Left', 
    '13': 'tbd - Atrium - Right', 
    '14': 'tbd - Ventricle', 
    '15': 'Endocardium - Ventricular', 
    '16': 'Ventricle - Trabeculated - Left', 
    '17': 'VCS - Distal', 
    '18': 'tbd - CCS, Valves', 
    '19': 'Ventricle - Compact - Left',  
    '20': 'tbd - CCS, Valves', 
    '21': 'tbd - Ventricle', 
    '22': 'Endocardium - Ventricular', 
    '23': 'Adventitia - Coronary', 
    '24': 'Ventricle - Compact - Right', 
}}, inplace=True)
```

Example 44 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_sub, color=['annotation'], size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=10, frameon=False, legend_loc='on data')
```

Example 45 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='annotation',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 46 (python):
```python
# get annotation
annot_df['myocardium_annotation'] = adata_sub.obs['annotation'].reindex(annot_df.index)
annot_df.head()
```

Example 47 (unknown):
```unknown
structures = ['tbd - CCS, Valves']

# get index
indices = list(annot_df.index[annot_df['myocardium_annotation'].isin(structures)])
```

Example 48 (python):
```python
# subset
adata_sub = adata_vis[indices]

# # compute KNN using the cell2location output stored in adata.obsm
# bbknn
bbknn.bbknn(adata_sub, batch_key='sample_for_cell2loc', use_rep='q05_cell_abundance_w_sf_ndarray')

# Cluster spots into regions using scanpy
sc.tl.leiden(adata_sub, resolution=2)

# add region as categorical variable
adata_sub.obs["region_cluster"] = adata_sub.obs["leiden"].astype("category")

# compute UMAP using KNN graph based on the cell2location output
sc.tl.umap(adata_sub, min_dist = 0.2, spread = 1)  # n_components=3
```

Example 49 (unknown):
```unknown
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/compat/_overloaded_dict.py:179: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  ovld.data[key] = neighbors
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 50 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [4, 4]}):
    sc.pl.umap(adata_sub, color=['week','JC_edit'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.2,
               legend_fontsize=14, frameon=False, components='all')
```

Example 51 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [4, 4]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 52 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [4, 4]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], groups=['11','14','21','23'],size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 53 (python):
```python
for structure,celltypes in celltypes_for_annotation.items():
    print(f'##### {structure} #####')
    with mpl.rc_context({'axes.facecolor':  'white',
                         'figure.figsize': [4, 4]}):
        sc.pl.umap(adata_sub, color=[f'{x}_minmax' for x in celltypes], size=20,
                   color_map = 'RdPu', ncols = 4, wspace=0.3, vmax='p99.98',
                   legend_fontsize=14, frameon=False)
```

Example 54 (unknown):
```unknown
##### Atrium #####
```

Example 55 (unknown):
```unknown
##### Ventricle #####
```

Example 56 (unknown):
```unknown
##### CCS #####
```

Example 57 (unknown):
```unknown
##### Adventitia #####
```

Example 58 (unknown):
```unknown
##### LN #####
```

Example 59 (unknown):
```unknown
##### Valve #####
```

Example 60 (unknown):
```unknown
##### Endocardium #####
```

Example 61 (unknown):
```unknown
##### Epicardium #####
```

Example 62 (unknown):
```unknown
##### DuctusArteriosus #####
```

Example 63 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='region_cluster',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 64 (python):
```python
adata_sub.obs['annotation'] = adata_sub.obs['region_cluster']
adata_sub.obs['annotation'] = adata_sub.obs['annotation'].astype('str')
adata_sub.obs.replace({'annotation': {
    '0': 'VCS - Proximal', 
    '1': 'VCS - Proximal', 
    '2': 'tbd - AVring, Valves', 
    '3': 'tbd - AVring, Valves', 
    '4': 'Ventricle - Compact - Right', 
    '5': 'Ventricle - Trabeculated - Left', 
    '6': 'tbd - AVring, Valves', 
    '7': 'tbd - AVring, Valves',  
    '8': 'Endocardial cusion',  
    '9': 'tbd - Nodes',  
    '10': 'tbd - AVring, Valves', 
    '11': 'VCS - Proximal', 
    '12': 'tbd - AVring, Valves', 
    '13': 'tbd - AVring, Valves', 
    '14': 'tbd - AVring, Valves', 
    '15': 'Adventitia - Coronary', 
    '16': 'Endocardial cusion', 
}}, inplace=True)
```

Example 65 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_sub, color=['annotation'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=10, frameon=False, legend_loc='on data')
```

Example 66 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='annotation',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 67 (python):
```python
# get annotation
annot_df['CCS-Valve_annotation'] = adata_sub.obs['annotation'].reindex(annot_df.index)
annot_df.head()
```

Example 68 (unknown):
```unknown
structures = ['tbd - Atrium - Right','tbd - Atrium - Left']

# get index
indices = list(annot_df.index[annot_df['myocardium_annotation'].isin(structures)])
```

Example 69 (python):
```python
# subset
adata_sub = adata_vis[indices]

# # compute KNN using the cell2location output stored in adata.obsm
# bbknn
bbknn.bbknn(adata_sub, batch_key='sample_for_cell2loc', use_rep='q05_cell_abundance_w_sf_ndarray')

# Cluster spots into regions using scanpy
sc.tl.leiden(adata_sub, resolution=1.5)

# add region as categorical variable
adata_sub.obs["region_cluster"] = adata_sub.obs["leiden"].astype("category")

# compute UMAP using KNN graph based on the cell2location output
sc.tl.umap(adata_sub, min_dist = 0.2, spread = 1)  # n_components=3
```

Example 70 (unknown):
```unknown
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/compat/_overloaded_dict.py:179: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  ovld.data[key] = neighbors
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 71 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['week','JC_edit'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False, components='all')
```

Example 72 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['sample'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.2,
               legend_fontsize=14, frameon=False, components='all')
```

Example 73 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 74 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], groups=['5','13'],size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 75 (python):
```python
for structure,celltypes in celltypes_for_annotation.items():
    print(f'##### {structure} #####')
    with mpl.rc_context({'axes.facecolor':  'white',
                         'figure.figsize': [3, 3]}):
        sc.pl.umap(adata_sub, color=[f'{x}_minmax' for x in celltypes], size=20,
                   color_map = 'RdPu', ncols = 4, wspace=0.3, vmax='p99.98',
                   legend_fontsize=14, frameon=False)
```

Example 76 (unknown):
```unknown
##### Atrium #####
```

Example 77 (unknown):
```unknown
##### Ventricle #####
```

Example 78 (unknown):
```unknown
##### CCS #####
```

Example 79 (unknown):
```unknown
##### Adventitia #####
```

Example 80 (unknown):
```unknown
##### LN #####
```

Example 81 (unknown):
```unknown
##### Valve #####
```

Example 82 (unknown):
```unknown
##### Endocardium #####
```

Example 83 (unknown):
```unknown
##### Epicardium #####
```

Example 84 (unknown):
```unknown
##### DuctusArteriosus #####
```

Example 85 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='region_cluster',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 86 (python):
```python
adata_sub.obs['annotation'] = adata_sub.obs['region_cluster']
adata_sub.obs['annotation'] = adata_sub.obs['annotation'].astype('str')
adata_sub.obs.replace({'annotation': {
    '0': 'Atrium - Left', 
    '1': 'Atrium - Right', 
    '2': 'Adventitia - Coronary', 
    '3': 'Atrium - Left', 
    '4': 'Atrium - Right', 
    '5': 'Endocardium - Atrial', 
    '6': 'Atrium - Left', 
    '7': 'Atrium - Left', 
    '8': 'Atrium - Left', 
    '9': 'tbd - Nodes', 
    '10': 'tbd - Nodes', 
    '11': 'Atrium - Left', 
    '12': 'Atrium - Left', 
    '13': 'Endocardium - Atrial', 
    '14': 'Uncertain', 
}}, inplace=True)
```

Example 87 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['annotation'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=10, frameon=False, legend_loc='on data')
```

Example 88 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='annotation',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 89 (python):
```python
# get annotation
annot_df['Atrium_annotation'] = adata_sub.obs['annotation'].reindex(annot_df.index)
annot_df.head()
```

Example 90 (unknown):
```unknown
celltypes_for_annotation = {
    'Atrium':['AtrialCardiomyocytesLeft','AtrialCardiomyocytesRight'],
    'Ventricle':['VentricularCardiomyocytesLeftCompact',
                 'VentricularCardiomyocytesRightCompact',
                 'VentricularCardiomyocytesLeftTrabeculated',
                 'VentricularCardiomyocytesRightTrabeculated'],
    'CCS':['SinoatrialNodeCardiomyocytes',
             'AtrioventricularNodeCardiomyocytes',
             'VentricularConductionSystemProximal',
             'VentricularConductionSystemDistal',],
    'Adventitia':['GreatVesselAdventitialFibroblasts','CoronaryVesselAdventitialFibroblasts'],
    'LN':['LymphNodeFibroblasticReticularCells'],
    'Valve':['ValveInterstitialCells'],
    'Endocardium':['EndocardialCells','EndocardialCushionCells'],
    'Epicardium':['MesothelialEpicardialCells','EpicardiumDerivedCells'],
    'DuctusArteriosus':['DuctusArteriosusSmoothMuscleCells'],
    'Vessels':['GreatVesselSmoothMuscleCells',
 'CoronarySmoothMuscleCells',
 'CoronaryPericytes',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselVenousEndothelialCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryCapillaryEndothelialCells',]
}
```

Example 91 (unknown):
```unknown
structures = ['Vessels']

# get index
indices = list(annot_df.index[annot_df['global_annotation'].isin(structures)])
```

Example 92 (python):
```python
# subset
adata_sub = adata_vis[indices]

# # compute KNN using the cell2location output stored in adata.obsm
# bbknn
bbknn.bbknn(adata_sub, batch_key='sample_for_cell2loc', use_rep='q05_cell_abundance_w_sf_ndarray')

# Cluster spots into regions using scanpy
sc.tl.leiden(adata_sub, resolution=1.5)

# add region as categorical variable
adata_sub.obs["region_cluster"] = adata_sub.obs["leiden"].astype("category")

# compute UMAP using KNN graph based on the cell2location output
sc.tl.umap(adata_sub, min_dist = 0.2, spread = 1)  # n_components=3
```

Example 93 (unknown):
```unknown
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/compat/_overloaded_dict.py:179: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  ovld.data[key] = neighbors
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 94 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['week','JC_edit'], size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=14, frameon=False, components='all')
```

Example 95 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['sample'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.2,
               legend_fontsize=14, frameon=False, components='all')
```

Example 96 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 97 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], groups=['13'],size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 98 (python):
```python
for structure,celltypes in celltypes_for_annotation.items():
    print(f'##### {structure} #####')
    with mpl.rc_context({'axes.facecolor':  'white',
                         'figure.figsize': [3, 3]}):
        sc.pl.umap(adata_sub, color=[f'{x}_minmax' for x in celltypes], size=20,
                   color_map = 'RdPu', ncols = 4, wspace=0.3, vmax='p99.98',
                   legend_fontsize=14, frameon=False)
```

Example 99 (unknown):
```unknown
##### Atrium #####
```

Example 100 (unknown):
```unknown
##### Ventricle #####
```

Example 101 (unknown):
```unknown
##### CCS #####
```

Example 102 (unknown):
```unknown
##### Adventitia #####
```

Example 103 (unknown):
```unknown
##### LN #####
```

Example 104 (unknown):
```unknown
##### Valve #####
```

Example 105 (unknown):
```unknown
##### Endocardium #####
```

Example 106 (unknown):
```unknown
##### Epicardium #####
```

Example 107 (unknown):
```unknown
##### DuctusArteriosus #####
```

Example 108 (unknown):
```unknown
##### Vessels #####
```

Example 109 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='region_cluster',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 110 (python):
```python
adata_sub.obs['annotation'] = adata_sub.obs['region_cluster']
adata_sub.obs['annotation'] = adata_sub.obs['annotation'].astype('str')
adata_sub.obs.replace({'annotation': {
    '0': 'Adventitia - Coronary', 
    '1': 'Great vessel', 
    '2': 'Adventitia - GV', 
    '3': 'tbd - AVring, Valves', 
    '4': 'Great vessel', 
    '5': 'Adventitia - GV', 
    '6': 'Great vessel', 
    '7': 'Great vessel', 
    '8': 'Great vessel', 
    '9': 'Great vessel', 
    '10': 'Adventitia - Coronary', 
    '11': 'Great vessel', 
    '12': 'Adventitia - GV', 
    '13': 'Great vessel', 
    '14': 'Great vessel', 
    '15': 'Atrium - Left', 
    '16': 'Great vessel', 
    '17': 'Coronary vessel', 
    '18': 'Great vessel', 
    '19': 'Coronary vessel', 
    '20': 'tbd - Ventricle', 
}}, inplace=True)
```

Example 111 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['annotation'], size=20,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=10, frameon=False, legend_loc='on data')
```

Example 112 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='annotation',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 113 (python):
```python
# get annotation
annot_df['Vessels_annotation'] = adata_sub.obs['annotation'].reindex(annot_df.index)
annot_df.head()
```

Example 114 (unknown):
```unknown
structures = ['tbd - Nodes']

# get index
indices = list(annot_df.index[(annot_df['CCS-Valve_annotation'].isin(structures))|(annot_df['Atrium_annotation'].isin(structures))])
indices = list(set(indices))
```

Example 115 (python):
```python
# subset
adata_sub = adata_vis[indices]

# # compute KNN using the cell2location output stored in adata.obsm
# bbknn
bbknn.bbknn(adata_sub, batch_key='donor', use_rep='q05_cell_abundance_w_sf_ndarray')

# Cluster spots into regions using scanpy
sc.tl.leiden(adata_sub, resolution=1)

# add region as categorical variable
adata_sub.obs["region_cluster"] = adata_sub.obs["leiden"].astype("category")

# compute UMAP using KNN graph based on the cell2location output
sc.tl.umap(adata_sub, min_dist = 0.2, spread = 1, n_components=3)  # n_components=3
```

Example 116 (unknown):
```unknown
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/compat/_overloaded_dict.py:179: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  ovld.data[key] = neighbors
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 117 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['week','JC_edit'], size=50,
               color_map = 'RdPu', ncols = 3, wspace=0.7,
               legend_fontsize=14, frameon=False, components='all')
```

Example 118 (python):
```python
# show regions in UMAP coordinates
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['sample'], size=50,
               color_map = 'RdPu', ncols = 3, wspace=0.2,
               legend_fontsize=14, frameon=False, components='1,2')
```

Example 119 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], size=50,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 120 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['region_cluster'], groups=['6'],size=10,
               color_map = 'RdPu', ncols = 3, wspace=0.2,legend_loc='on data',
               legend_fontsize=10, frameon=False, components='all')
```

Example 121 (python):
```python
for structure,celltypes in celltypes_for_annotation.items():
    print(f'##### {structure} #####')
    with mpl.rc_context({'axes.facecolor':  'white',
                         'figure.figsize': [3, 3]}):
        sc.pl.umap(adata_sub, color=[f'{x}_minmax' for x in celltypes], size=50,
                   color_map = 'RdPu', ncols = 3, wspace=0.3, vmax='p99.98',
                   legend_fontsize=14, frameon=False, components='all')
```

Example 122 (unknown):
```unknown
##### Atrium #####
```

Example 123 (unknown):
```unknown
##### Ventricle #####
```

Example 124 (unknown):
```unknown
##### CCS #####
```

Example 125 (unknown):
```unknown
##### Adventitia #####
```

Example 126 (unknown):
```unknown
##### LN #####
```

Example 127 (unknown):
```unknown
##### Valve #####
```

Example 128 (unknown):
```unknown
##### Endocardium #####
```

Example 129 (unknown):
```unknown
##### Epicardium #####
```

Example 130 (unknown):
```unknown
##### DuctusArteriosus #####
```

Example 131 (unknown):
```unknown
##### Vessels #####
```

Example 132 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='region_cluster',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 133 (python):
```python
adata_sub.obs['annotation'] = adata_sub.obs['region_cluster']
adata_sub.obs['annotation'] = adata_sub.obs['annotation'].astype('str')
adata_sub.obs.replace({'annotation': {
    '0': 'Atrium - Left', 
    '1': 'Atrium - Left', 
    '2': 'tbd - AVring, Valves', 
    '3': 'tbd - AVring, Valves', 
    '4': 'VCS - Proximal', 
    '5': 'AVnode', 
    '6': 'AVnode', 
    '7': 'SAnode', 
    '8': 'Atrium - Left', 
}}, inplace=True)
```

Example 134 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [3, 3]}):
    sc.pl.umap(adata_sub, color=['annotation'], size=50,
               color_map = 'RdPu', ncols = 3, wspace=0.3,
               legend_fontsize=10, frameon=False, legend_loc='on data', components='all')
```

Example 135 (python):
```python
adata_sub.var_names_make_unique()
sc.pl.dotplot(adata_sub,
              cellnames, 
              groupby='annotation',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              expression_cutoff=0.1
             )
```

Example 136 (python):
```python
# get annotation
annot_df['Nodes_annotation'] = adata_sub.obs['annotation'].reindex(annot_df.index)
annot_df.head()
```

Example 137 (python):
```python
# prepare column
annot_df['cell2loc-abundance_annotation'] = np.nan
```

Example 138 (python):
```python
# annotate "Ductus arteriosus" based on DuctusArteriosusSMC abuncance
thresh = 5

adata_vis.obs['DuctusArteriosusSmoothMuscleCells'].hist(bins=100)
plt.ylim(0,200)
plt.axvline(x=thresh, color='r', linestyle='--')
plt.show()

obsnames = adata_vis.obs_names[adata_vis.obs['DuctusArteriosusSmoothMuscleCells']>thresh]
annot_df.loc[obsnames,'cell2loc-abundance_annotation'] = 'Ductus arteriosus'

len(obsnames)
```

Example 139 (python):
```python
annotation_final = []
for ind in annot_df.index:
    l = list(annot_df.loc[ind,['myocardium_annotation', 'CCS-Valve_annotation',
                                   'Atrium_annotation', 'Vessels_annotation', 'Nodes_annotation',
                                   'cell2loc-abundance_annotation']])
    l = [x for x in l if x==x]
    if len(l)>0:
        ll = [x for x in l if 'tbd -' not in x]
        if len(ll)==1:
            annotation_final.append(ll[0])
        # elif l[-1]=='Epicardium':
        #     annotation_final.append(l[-1])
        elif l[-1]=='Ductus arteriosus':
            annotation_final.append(l[-1])
        else:
            annotation_final.append(' | '.join(l))
    else:
        annotation_final.append(np.nan)
        
annot_df['pre-final'] = annotation_final.copy()
annot_df.head()
```

Example 140 (unknown):
```unknown
set(annot_df['pre-final'])
```

Example 141 (unknown):
```unknown
{'AVnode',
 'Adventitia - Coronary',
 'Adventitia - GV',
 'Atrium - Left',
 'Atrium - Right',
 'Coronary vessel',
 'Ductus arteriosus',
 'Endocardial cusion',
 'Endocardium - Atrial',
 'Endocardium - Ventricular',
 'Great vessel',
 'SAnode',
 'Uncertain',
 'VCS - Distal',
 'VCS - Proximal',
 'Ventricle - Compact - Left',
 'Ventricle - Compact - Right',
 'Ventricle - Trabeculated - Left',
 'Ventricle - Trabeculated - Right',
 'tbd - AVring, Valves',
 'tbd - CCS, Valves | tbd - AVring, Valves',
 'tbd - CCS, Valves | tbd - Nodes | tbd - AVring, Valves',
 'tbd - Ventricle'}
```

Example 142 (unknown):
```unknown
# rename some of them
annot_df.replace({'pre-final':{
    'tbd - CCS, Valves | tbd - AVring, Valves':'tbd - AVring, Valves',
    'tbd - CCS, Valves | tbd - Nodes | tbd - AVring, Valves':'tbd - AVring, Valves',
    'tbd - Atrium - Left | tbd - Nodes | tbd - AVring, Valves':'tbd - AVring, Valves'
}},inplace=True)
set(annot_df['pre-final'])
```

Example 143 (unknown):
```unknown
{'AVnode',
 'Adventitia - Coronary',
 'Adventitia - GV',
 'Atrium - Left',
 'Atrium - Right',
 'Coronary vessel',
 'Ductus arteriosus',
 'Endocardial cusion',
 'Endocardium - Atrial',
 'Endocardium - Ventricular',
 'Great vessel',
 'SAnode',
 'Uncertain',
 'VCS - Distal',
 'VCS - Proximal',
 'Ventricle - Compact - Left',
 'Ventricle - Compact - Right',
 'Ventricle - Trabeculated - Left',
 'Ventricle - Trabeculated - Right',
 'tbd - AVring, Valves',
 'tbd - Ventricle'}
```

Example 144 (python):
```python
# add manual annotation
annot_df['JC_edit'] = adata_vis.obs['JC_edit'].reindex(annot_df.index)
annot_df.head()
```

Example 145 (python):
```python
# cross table
pd.crosstab(annot_df['pre-final'],annot_df['JC_edit'])
```

Example 146 (unknown):
```unknown
# prepare column
annot_df['final'] = annot_df['pre-final'].copy()
```

Example 147 (unknown):
```unknown
# AVN
obsnames = annot_df.index[annot_df['JC_edit']=='AVN']
annot_df.loc[obsnames,'final'] = 'AVnode'
# LN
obsnames = annot_df.index[annot_df['JC_edit']=='LN']
annot_df.loc[obsnames,'final'] = 'LN'
# Epicardium
obsnames = annot_df.index[annot_df['JC_edit']=='Epicardium']
annot_df.loc[obsnames,'final'] = 'Epicardium'
```

Example 148 (python):
```python
annots = ['AV ring','AV valves','Aortic valve','Valve apparatus','Epicardium','Coronary artery','Great vessels','Connective tissue']
for anno in annots:
    obsnames = annot_df.index[(annot_df['JC_edit']==anno)&\
                              ([('tbd -' in x)|(x=='Uncertain') for x in annot_df['pre-final']])]
                              
    print(f'{anno}, n_spot to modify: {len(obsnames)}')
    if anno=='Connective tissue':
        annot_df.loc[obsnames,'final'] = 'AV ring'
    else:
        annot_df.loc[obsnames,'final'] = anno
```

Example 149 (unknown):
```unknown
AV ring, n_spot to modify: 343
AV valves, n_spot to modify: 421
Aortic valve, n_spot to modify: 229
Valve apparatus, n_spot to modify: 205
Epicardium, n_spot to modify: 128
Coronary artery, n_spot to modify: 4
Great vessels, n_spot to modify: 518
Connective tissue, n_spot to modify: 7
```

Example 150 (python):
```python
obsnames = annot_df.index[(annot_df['pre-final']=='Coronary vessel')&\
                          (annot_df['JC_edit']=='Great vessels')]
                              
print(f'n_spot to modify: {len(obsnames)}')
annot_df.loc[obsnames,'final'] = 'Great vessel'
```

Example 151 (unknown):
```unknown
n_spot to modify: 105
```

Example 152 (python):
```python
obsnames = annot_df.index[(annot_df['JC_edit']=='Myocardium - Atrial')&\
                              ([('tbd -' in x)|(x=='Uncertain') for x in annot_df['pre-final']])]
print(len(obsnames))
ad = adata_vis[obsnames].copy()
sns.scatterplot(ad.obs['AtrialCardiomyocytesRight'],ad.obs['AtrialCardiomyocytesLeft'],
                hue=annot_df.loc[obsnames,'final'])
plt.legend(loc='upper right',bbox_to_anchor=(2.5, 1))
plt.show()

# decide right or left based on cell2loc abundance
df = ad.obs.loc[obsnames,['AtrialCardiomyocytesRight','AtrialCardiomyocytesLeft']]
df['annotation'] = 'Atrium - Left'
obsnames_right = df.index[df['AtrialCardiomyocytesRight']>df['AtrialCardiomyocytesLeft']]
df.loc[obsnames_right,'annotation'] = 'Atrium - Right'

# add annotation
annot_df.loc[obsnames,'final'] = df['annotation'].copy()

sns.scatterplot(ad.obs['AtrialCardiomyocytesRight'],ad.obs['AtrialCardiomyocytesLeft'],
                hue=annot_df.loc[obsnames,'final'])
plt.legend(loc='upper right',bbox_to_anchor=(1.2, 1))
plt.show()
```

Example 153 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
```

Example 154 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
```

Example 155 (python):
```python
obsnames = annot_df.index[(annot_df['JC_edit']=='Myocardium - Ventricular - Compact')&\
                              ([('tbd -' in x)|(x=='Uncertain') for x in annot_df['pre-final']])]
print(len(obsnames))
ad = adata_vis[obsnames].copy()
sns.scatterplot(ad.obs['VentricularCardiomyocytesRightCompact'],ad.obs['VentricularCardiomyocytesLeftCompact'],
                hue=annot_df.loc[obsnames,'pre-final'])
plt.legend(loc='upper right',bbox_to_anchor=(2, 1))
plt.show()

# decide right or left based on cell2loc abundance
df = ad.obs.loc[obsnames,['VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftCompact']]
df['annotation'] = 'Ventricle - Compact - Left'
obsnames_right = df.index[df['VentricularCardiomyocytesRightCompact']>df['VentricularCardiomyocytesLeftCompact']]
df.loc[obsnames_right,'annotation'] = 'Ventricle - Compact - Right'

# add annotation
annot_df.loc[obsnames,'final'] = df['annotation'].copy()

sns.scatterplot(ad.obs['VentricularCardiomyocytesRightCompact'],ad.obs['VentricularCardiomyocytesLeftCompact'],
                hue=annot_df.loc[obsnames,'final'])
plt.legend(loc='upper right',bbox_to_anchor=(2, 1))
plt.show()
```

Example 156 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
```

Example 157 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
```

Example 158 (python):
```python
obsnames = annot_df.index[(annot_df['JC_edit'].isin(['Myocardium - Papillary Muscle',
                                                     'Myocardium - Ventricular - Trabeculated',
                                                     'Bundle branch - left','Bundle branch - right'
                                                    ]))&\
                              ([('tbd -' in x)|(x=='Uncertain') for x in annot_df['pre-final']])]
print(len(obsnames))
ad = adata_vis[obsnames].copy()
sns.scatterplot(ad.obs['VentricularCardiomyocytesRightTrabeculated'],ad.obs['VentricularCardiomyocytesLeftTrabeculated'],
                hue=annot_df.loc[obsnames,'pre-final'])
plt.legend(loc='upper right',bbox_to_anchor=(2, 1))
plt.show()

# decide right or left based on cell2loc abundance
df = ad.obs.loc[obsnames,['VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesLeftTrabeculated']]
df['annotation'] = 'Ventricle - Trabeculated - Left'
obsnames_right = df.index[df['VentricularCardiomyocytesRightTrabeculated']>df['VentricularCardiomyocytesLeftTrabeculated']]
df.loc[obsnames_right,'annotation'] = 'Ventricle - Trabeculated - Right'

# add annotation
annot_df.loc[obsnames,'final'] = df['annotation'].copy()

sns.scatterplot(ad.obs['VentricularCardiomyocytesRightTrabeculated'],ad.obs['VentricularCardiomyocytesLeftTrabeculated'],
                hue=annot_df.loc[obsnames,'final'])
plt.legend(loc='upper right',bbox_to_anchor=(2, 1))
plt.show()
```

Example 159 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/anndata/_core/anndata.py:1830: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
```

Example 160 (python):
```python
/home/jovyan/my-conda-envs/cellpymc/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
```

Example 161 (unknown):
```unknown
# refine name
annot_df.replace({'final':{
    'Coronary artery':'Coronary vessel',
    'Endocardium - Atrial':'Endocardium',
    'Endocardium - Ventricular':'Endocardium',
    'Epicardium - Atrial':'Epicardium',
    'Epicardium - Ventricular':'Epicardium',
    'Great vessels':'Great vessel',
}},inplace=True)
set(annot_df['final'])
```

Example 162 (unknown):
```unknown
{'AV ring',
 'AV valves',
 'AVnode',
 'Adventitia - Coronary',
 'Adventitia - GV',
 'Aortic valve',
 'Atrium - Left',
 'Atrium - Right',
 'Coronary vessel',
 'Ductus arteriosus',
 'Endocardial cusion',
 'Endocardium',
 'Epicardium',
 'Great vessel',
 'LN',
 'SAnode',
 'VCS - Distal',
 'VCS - Proximal',
 'Valve apparatus',
 'Ventricle - Compact - Left',
 'Ventricle - Compact - Right',
 'Ventricle - Trabeculated - Left',
 'Ventricle - Trabeculated - Right'}
```

Example 163 (python):
```python
# cross table
pd.crosstab(annot_df['final'],annot_df['JC_edit'])
```

Example 164 (python):
```python
adata_vis.obs['annotation_final'] = annot_df['final'].reindex(adata_vis.obs_names)
adata_vis.obs['annotation_final'] = adata_vis.obs['annotation_final'].astype('category')
```

Example 165 (python):
```python
with mpl.rc_context({'axes.facecolor':  'white',
                     'figure.figsize': [6, 6]}):
    sc.pl.umap(adata_vis, color=['annotation_final','JC_edit'], size=5,
               color_map = 'RdPu', ncols = 3, wspace=0.1,
               legend_fontsize=10, frameon=False, legend_loc='on data')
```

Example 166 (python):
```python
annot_df.to_csv('/nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_spot-annotation.csv')
adata_vis.write('/nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_raw.h5ad')
```

Example 167 (unknown):
```unknown
# rclone to gdrive
rclone copy /nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_raw.h5ad \
gdrive:JamesC_Kazumasa/Foetal_Heart/SanjayShinha/toSinhalab/anndata/Visium/
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_lymphoid.html

**Contents:**
- Variables¶
- Read in data¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 5 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
# import session_info
# session_info.show()
```

Example 3 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 4 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 5 (unknown):
```unknown
!ls /lustre/scratch126/cellgen/team205/kk18/xenium/objects/foetal/subsets
```

Example 6 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'LymphoidCells'
```

Example 7 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 8 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 9 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 10 (unknown):
```unknown
AnnData object with n_obs × n_vars = 3116 × 4614
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 11 (python):
```python
adata.X.data[:5]
```

Example 12 (unknown):
```unknown
array([3.1345382, 3.1345382, 3.1345382, 3.1345382, 3.1345382],
      dtype=float32)
```

Example 13 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 14 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 15 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 16 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 17 (unknown):
```unknown
CPU times: user 1.94 s, sys: 82.8 ms, total: 2.03 s
Wall time: 2.07 s
```

Example 18 (python):
```python
# markers for fine-grained cell types
markers={
     'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B','TRAC','TRBC1','TRDC','TRGC1'],
    'naive': ['TCF7', 'LEF1', 'SELL'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2'],
    'cytotoxic': ['PRF1', 'GZMB', 'GZMH', 'NKG7'],
    'NK': ['KLRF1', 'KLRD1', 'NCAM1','FCGR3A','IFNG'],
    'ILC3': ['KIT', 'IL18R1','RORC','IL17A'],
    
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1','IL7R',],
    '':['CCR7','TNFRSF13B',],
    'ProB':['KIT','SPN','CD34'],
    'B1':['CD27','CCR10','MS4A1','SPN'],
    'Plasma': ['CD27','CCR10','CD38','SDC1','JCAIN'],
    'Abs':['IGHM','IGHD', 'IGHG1','IGHG2', 'IGHG3','IGHG4', 'IGHA1','IGHE','IGLC1','IGKC'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    
    
    'Cycling':['MKI67','TOP2A'],

    'TFs': ['TBX21', 'GATA3', 'RORC', 'BCL6',],
}

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]
    
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 19 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color="AIRE",
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 20 (unknown):
```unknown
resolution_sel = 1
```

Example 21 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 22 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: T cell, naive, CD4T_reg, etc.
```

Example 23 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              markers_others, 
              groupby=f'leiden_{str(resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 24 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 25 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 26 (unknown):
```unknown
[3.1345382 3.1345382 3.1345382 3.1345382 3.1345382]
```

Example 27 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 28 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 29 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'ThyroidEpithelialCells',
    '1':'SOX2_LAMB3_pos',
    '2':'LymphoidCells',
    '3':'LymphoidCells',
    '4':'ThyroidEpithelialCells',
    '5':'unassigned',
    '6':'LymphoidCells',
    '7':'ThyroidEpithelialCells',
    '8':'Erythrocytes',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 30 (python):
```python
/tmp/ipykernel_78172/3528645312.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 31 (unknown):
```unknown
tmp_annotation
ThyroidEpithelialCells    1520
LymphoidCells              800
SOX2_LAMB3_pos             461
unassigned                 283
Erythrocytes                52
Name: count, dtype: int64
```

Example 32 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 33 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['LymphoidCells'])]
```

Example 34 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 35 (unknown):
```unknown
AnnData object with n_obs × n_vars = 800 × 4614
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 36 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 37 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 800 × 4178
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 38 (python):
```python
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
```

Example 39 (unknown):
```unknown
(800, 4125)
```

Example 40 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 41 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 42 (unknown):
```unknown
number of hvgs: 859
```

Example 43 (python):
```python
2025-06-12 16:25:16,957 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-12 16:25:17,130 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-12 16:25:17,172 - harmonypy - INFO - Iteration 1 of 10
2025-06-12 16:25:17,255 - harmonypy - INFO - Iteration 2 of 10
2025-06-12 16:25:17,296 - harmonypy - INFO - Iteration 3 of 10
2025-06-12 16:25:17,325 - harmonypy - INFO - Converged after 3 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 44 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 45 (unknown):
```unknown
CPU times: user 1.52 s, sys: 97.6 ms, total: 1.62 s
Wall time: 1.62 s
```

Example 46 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 47 (unknown):
```unknown
sub_resolution_sel = 1
```

Example 48 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 49 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: T cell, naive, CD4T_reg, etc.
```

Example 50 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata_sub.var_names]

sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              markers_others, 
              groupby=f'leiden_{str(sub_resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 51 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 52 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 53 (unknown):
```unknown
[2.9061403 2.2662368 2.2662368 2.2662368 2.2662368]
```

Example 54 (python):
```python
# DEG analysis without other cell type markers
# with removing mid_grain markers
# remove mid_grain markers
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]

print(bdata.X.data[:5])
bdata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(bdata,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(bdata, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(bdata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 55 (unknown):
```unknown
[2.9061403 2.2662368 2.2662368 2.2662368 2.2662368]
```

Example 56 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:669: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns[key_added] = {}
```

Example 57 (python):
```python
myeloid_markers={
    'Mono':['CCR2','FCN1','VCAN','MPO'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163','MERTK'],
    'CX3CR1+':['CX3CR1','C3','TREM2','P2RY12'],
    'LYVE1+':['LYVE1','FOLR2'],
     'pDC':['IRF8','IRF4','IL3RA'],
     'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'Megakaryocyte':['ITGA2B','MPL','ITGB3',],
    'Mast': ['KIT', 'CPA3','HDC','GATA2'],
    'Neutro':['MYB', 'MPO', 'CEACAM8','CXCR1','CXCR2'],
    'Cycling':['MKI67','TOP2A'],
}
for k,g in myeloid_markers.items():
    myeloid_markers[k] = [x for x in g if x in adata_sub.var_names]

sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=myeloid_markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 58 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: Mono, MP, CX3CR1+, etc.
```

Example 59 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 60 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=['celltypist_midmod2fine', 'conf_score_midmod2fine'],
                wspace=0.7)
```

Example 61 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'doublets', 
    '1':'InnateLymphoidCells',
    '2':'TCellsCD8pos',
    '3':'doublets',
    '4':'BCells',
    '5':'TCellsCD4pos',
    '6':'doublets',
    '7':'doublets',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 62 (python):
```python
/tmp/ipykernel_78172/3271777684.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 63 (unknown):
```unknown
fine_grain_manual
doublets               362
InnateLymphoidCells    153
TCellsCD8pos           140
BCells                 104
TCellsCD4pos            41
Name: count, dtype: int64
```

Example 64 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 65 (python):
```python
sc.tl.dendrogram(adata_sub,groupby='fine_grain_manual')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 66 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: doublets, InnateLymphoidCells, TCellsCD8pos, etc.
var_group_labels: T cell, naive, CD4T_reg, etc.
```

Example 67 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 68 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 69 (python):
```python
pd.crosstab(adata.obs['fine_grain_manual'],adata.obs['tissue_block_id'])
```

Example 70 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
                  spot_size=60,vmax='p100')
```

Example 71 (python):
```python
/tmp/ipykernel_78172/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 72 (python):
```python
/tmp/ipykernel_78172/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 73 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=80,vmax='p100')
```

Example 74 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 75 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 76 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 77 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 78 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 79 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 80 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 81 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 82 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 83 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 84 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 85 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 86 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 87 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 88 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 89 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 90 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 91 (python):
```python
/tmp/ipykernel_78172/1166615315.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 92 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 93 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_LymphoidCells_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no7_collect_fine-grained-annotations.html

**Contents:**
- Read in adata¶
- Add fine-grained annotation¶
- Save¶
- Output file for XeniumExplorer¶
- Plotting¶
- Cropping¶

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os
import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-12 20:59
```

Example 7 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 8 (python):
```python
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
adata
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'dendrogram_pca_harmony_leiden_1.0', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 10 (unknown):
```unknown
os.getcwd()
```

Example 11 (unknown):
```unknown
'/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/Xenium/5K/C194_Hst45/CamU'
```

Example 12 (python):
```python
adata.X.data[:5]
```

Example 13 (unknown):
```unknown
array([5., 1., 1., 2., 2.], dtype=float32)
```

Example 14 (python):
```python
latent_space = 'pca_harmony'
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color='celltypist_mid_fin',
                   )
```

Example 15 (python):
```python
adata.obs['celltypist_mid_fin'].value_counts()
```

Example 16 (unknown):
```unknown
celltypist_mid_fin
VentricularCardiomyocytes      188122
Fibroblasts                     49242
AtrialCardiomyocytes            47076
BloodVesselEndothelialCells     20055
MuralCells                      10986
PericardialCells                 8698
unassigned                       7967
Glia                             6976
EpicardialCells                  5206
EndocardialCells                 5202
MyeloidCells                     3965
LymphaticEndothelialCells        3674
LymphoidCells                    3116
Neurons                          1992
Name: count, dtype: int64
```

Example 17 (python):
```python
subset_adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
fine_grain_colname = 'fine_grain_12Jun2025'
```

Example 18 (python):
```python
!ls {subset_adata_dir}
```

Example 19 (unknown):
```unknown
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_AtrialCardiomyocytes_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_BloodVesselEndothelialCells_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_EndocardialCells_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_EpicardialCells_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_Fibroblasts_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_Glia_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_LymphaticEndothelialCells_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_LymphoidCells_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_MuralCells_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_MyeloidCells_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_Neurons_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_PericardialCells_lognorm.h5ad
C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_VentricularCardiomyocytes_lognorm.h5ad
```

Example 20 (python):
```python
file_list = os.listdir(subset_adata_dir)

filename_head = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_'
celltypes_to_add = [x.replace(filename_head,'').replace('_lognorm.h5ad','') \
                    for x in file_list if filename_head in x]
celltypes_to_add
```

Example 21 (unknown):
```unknown
['EpicardialCells',
 'PericardialCells',
 'EndocardialCells',
 'LymphaticEndothelialCells',
 'Fibroblasts',
 'AtrialCardiomyocytes',
 'MyeloidCells',
 'Glia',
 'VentricularCardiomyocytes',
 'MuralCells',
 'BloodVesselEndothelialCells',
 'Neurons',
 'LymphoidCells']
```

Example 22 (python):
```python
adata.obs[fine_grain_colname] =  adata.obs['celltypist_mid_fin'].astype('str').copy()
adata.obs['multi_celltypes_coarse'] = np.nan
```

Example 23 (python):
```python
for celltype in celltypes_to_add:
    print(celltype)
    if celltype=='LymphaticEndothelialCells':
        print('skip since the label of mid-grain and fine-grain are same')
        continue
    ad = sc.read_h5ad(f'{subset_adata_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_{celltype}_lognorm.h5ad',backed='r')
    print(ad.shape)
    # add cell type labels
    adata.obs.loc[ad.obs_names,fine_grain_colname] = ad.obs['fine_grain_manual']
    # add 'multi_celltypes_coarse'
    adata.obs.loc[ad.obs_names,'multi_celltypes_coarse'] = ad.obs['multi_celltypes_coarse']
adata.obs[fine_grain_colname].value_counts()
```

Example 24 (unknown):
```unknown
EpicardialCells
(5206, 4657)
PericardialCells
```

Example 25 (python):
```python
/tmp/ipykernel_3225005/343326667.py:11: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '['No', 'No', 'No', 'No', 'No', ..., 'No', 'No', 'No', 'No', 'No']
Length: 5206
Categories (2, object): ['No', 'Yes']' has dtype incompatible with float64, please explicitly cast to a compatible dtype first.
  adata.obs.loc[ad.obs_names,'multi_celltypes_coarse'] = ad.obs['multi_celltypes_coarse']
```

Example 26 (unknown):
```unknown
(8698, 4737)
EndocardialCells
(5202, 4492)
LymphaticEndothelialCells
skip since the label of mid-grain and fine-grain are same
Fibroblasts
(49242, 4999)
AtrialCardiomyocytes
(47076, 5000)
MyeloidCells
(3965, 4505)
Glia
(6976, 4699)
VentricularCardiomyocytes
(188122, 5001)
MuralCells
(10986, 4771)
BloodVesselEndothelialCells
(20055, 4950)
Neurons
(1992, 4270)
LymphoidCells
(3116, 4614)
```

Example 27 (unknown):
```unknown
fine_grain_12Jun2025
VentricularCardiomyocytes           104353
unassigned                           74123
Fibroblasts                          32842
VentricularCardiomyocytesCycling     30516
unclassified                         13129
                                     ...  
ErythrocytesCycling                     65
EntericLikeNeurons                      45
Megakaryocytes                          42
TCellsCD4pos                            41
DendriticCells                          26
Name: count, Length: 68, dtype: int64
```

Example 28 (python):
```python
adata.obs['multi_celltypes_coarse'].value_counts()
```

Example 29 (unknown):
```unknown
multi_celltypes_coarse
No     315108
Yes     35528
Name: count, dtype: int64
```

Example 30 (python):
```python
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color=fine_grain_colname,
                   )
```

Example 31 (python):
```python
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color='multi_celltypes_coarse',
                   )
```

Example 32 (python):
```python
adata.write(path_adata)
adata
```

Example 33 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'fine_grain_12Jun2025'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'dendrogram_pca_harmony_leiden_1.0', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'fine_grain_12Jun2025_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 34 (unknown):
```unknown
'/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
```

Example 35 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    df = slide.obs[['cell_id',fine_grain_colname]]
    df.columns = ['cell_id','group']
    df.to_csv(f'./{tissue_id}_cellgroup_XR_{fine_grain_colname}.csv',index=False)
```

Example 36 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=[fine_grain_colname],
                  groups=['SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells'],
                  spot_size=60,vmax='p100')
```

Example 37 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=[fine_grain_colname],
                  groups=['MacrophagesCX3CR1pos','MacrophagesLYVE1pos'],
                  spot_size=60,vmax='p100')
```

Example 38 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=[fine_grain_colname],
                  groups=['ParasympatheticNeurons','SympatheticNeurons','EntericLikeNeurons'],
                  spot_size=60,vmax='p100')
```

Example 39 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=[fine_grain_colname],
                  groups=['LymphoidCells'],
                  spot_size=60,vmax='p100')
```

Example 40 (python):
```python
tissue_id = 'C194-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]
sc.pl.spatial(slide,color=[fine_grain_colname],
              groups=['SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells','ParasympatheticNeurons','MacrophagesCX3CR1pos','MacrophagesLYVE1pos'],
              spot_size=20,vmax='p100',
              crop_coord=(4500,7000,4000,6000)
             )
```

Example 41 (python):
```python
tissue_id = 'Hst45-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]
sc.pl.spatial(slide,color=[fine_grain_colname],
              groups=['SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells','ParasympatheticNeurons','MacrophagesCX3CR1pos','MacrophagesLYVE1pos'],
              spot_size=60,vmax='p100',
              crop_coord=(6000,7000,500,3000)
             )
```

Example 42 (python):
```python
tissue_id = 'Hst45-HEA-0-FFPE-1'
slide = adata[adata.obs['tissue_block_id']==tissue_id]
sc.pl.spatial(slide,color=[fine_grain_colname],
              groups=['SinoatrialNodePacemakerCells','ParasympatheticNeurons','TCellsCD8pos','LymphaticEndothelialCells'],
              spot_size=40,vmax='p100',
              crop_coord=(6000,7000,500,3000)
             )
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig5_Trisomy21/no06_euploid-trisomy21_post-scVI_correcting-donor-region_n-layers-2.html

**Contents:**
- Read in original adata¶
- Add scVI latent space¶
- Find neighbors, UMAP/Clustering¶
- Inspecting each cell types¶
- Plotting¶

**Examples:**

Example 1 (python):
```python
import scanpy as sc
import pandas as pd
import numpy as np
import anndata
import scipy

import os

import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import warnings
warnings.simplefilter("ignore", UserWarning)
```

Example 2 (python):
```python
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 3 (python):
```python
import session_info
session_info.show()
```

Example 4 (python):
```python
-----
anndata             0.9.2
matplotlib          3.7.2
numpy               1.22.4
pandas              1.5.3
scanpy              1.9.3
scipy               1.10.1
seaborn             0.12.2
session_info        1.0.0
-----
```

Example 5 (python):
```python
PIL                         10.0.0
anyio                       NA
arrow                       1.2.3
asciitree                   NA
asttokens                   NA
attr                        23.1.0
attrs                       23.1.0
babel                       2.12.1
backcall                    0.2.0
brotli                      1.0.9
certifi                     2023.11.17
cffi                        1.15.1
charset_normalizer          3.2.0
cloudpickle                 3.0.0
colorama                    0.4.6
comm                        0.1.4
cycler                      0.10.0
cython_runtime              NA
dask                        2023.5.0
dateutil                    2.8.2
debugpy                     1.6.8
decorator                   5.1.1
defusedxml                  0.7.1
executing                   1.2.0
fasteners                   0.19
fastjsonschema              NA
fqdn                        NA
h5py                        3.9.0
idna                        3.4
igraph                      0.10.6
importlib_metadata          NA
importlib_resources         NA
ipykernel                   6.25.1
isoduration                 NA
jedi                        0.19.0
jinja2                      3.1.2
joblib                      1.3.2
json5                       NA
jsonpointer                 2.0
jsonschema                  4.19.0
jsonschema_specifications   NA
jupyter_events              0.7.0
jupyter_server              2.7.1
jupyterlab_server           2.24.0
kiwisolver                  1.4.5
leidenalg                   0.10.1
llvmlite                    0.38.1
markupsafe                  2.1.3
mpl_toolkits                NA
natsort                     8.4.0
nbformat                    5.9.2
numba                       0.55.2
numcodecs                   0.12.1
opt_einsum                  v3.3.0
overrides                   NA
packaging                   23.1
parso                       0.8.3
patsy                       0.5.3
pexpect                     4.8.0
pickleshare                 0.7.5
pkg_resources               NA
plotly                      5.16.1
prometheus_client           NA
prompt_toolkit              3.0.39
psutil                      5.9.5
ptyprocess                  0.7.0
pure_eval                   0.2.2
pyarrow                     15.0.2
pydev_ipython               NA
pydevconsole                NA
pydevd                      2.9.5
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pygments                    2.16.1
pyparsing                   3.0.9
pythonjsonlogger            NA
pytz                        2023.3
referencing                 NA
requests                    2.31.0
rfc3339_validator           0.1.4
rfc3986_validator           0.1.1
rpds                        NA
ruamel                      NA
send2trash                  NA
six                         1.16.0
sklearn                     1.3.0
sniffio                     1.3.0
socks                       1.7.1
sphinxcontrib               NA
stack_data                  0.6.2
statsmodels                 0.14.0
texttable                   1.6.7
threadpoolctl               3.2.0
tlz                         0.12.1
toolz                       0.12.1
torch                       1.13.1+cu117
tornado                     6.3.3
tqdm                        4.66.1
traitlets                   5.9.0
typing_extensions           NA
uri_template                NA
urllib3                     2.0.4
wcwidth                     0.2.6
webcolors                   1.13
websocket                   1.6.2
yaml                        6.0.1
zarr                        2.16.1
zipp                        NA
zmq                         25.1.1
zstandard                   0.19.0
```

Example 6 (unknown):
```unknown
-----
IPython             8.12.0
jupyter_client      8.3.0
jupyter_core        4.12.0
jupyterlab          4.0.5
notebook            7.0.2
-----
Python 3.8.17 (default, Jul  5 2023, 21:04:15) [GCC 11.2.0]
Linux-5.15.0-118-generic-x86_64-with-glibc2.17
-----
Session information updated at 2024-08-26 16:12
```

Example 7 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 8 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/nfs/team205/kk18/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 9 (unknown):
```unknown
figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 10 (python):
```python
# atlas
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor.h5ad')
adata
```

Example 11 (unknown):
```unknown
AnnData object with n_obs × n_vars = 83477 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'euploid_or_t21', 'donor_type', 'region_finest', 'flushed', 'scrublet_leiden', 'cluster_scrublet_score', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'celltypist_fine', 'conf_score_fine', 'coarse_grain_merged', 'fine_grain_merged'
    var: 'gene_id', 'gene_name_scRNA-0-0', 'feature_type-1', 'ambient_expression-0-1', 'ambient_expression-1-1', 'ambient_expression-10-1', 'ambient_expression-11-1', 'ambient_expression-12-1', 'ambient_expression-13-1', 'ambient_expression-14-1', 'ambient_expression-2-1', 'ambient_expression-3-1', 'ambient_expression-4-1', 'ambient_expression-5-1', 'ambient_expression-6-1', 'ambient_expression-7-1', 'ambient_expression-8-1', 'ambient_expression-9-1', 'mt-1', 'ribo-1', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
```

Example 12 (python):
```python
adata.obs['region'].value_counts()
```

Example 13 (unknown):
```unknown
Heart                              32788
whole sample                       24433
Pericardial sac + RA + LA + IAS     5084
node                                4298
Left ventricle                      3888
Right ventricle                     3792
heart without node                  3624
Left atria                          3475
Great vessels                       2095
Name: region, dtype: int64
```

Example 14 (unknown):
```unknown
latent_file_name_list = os.listdir('/nfs/team205/heart/anndata_objects/Foetal/scVI/latent_variables')
latent_file_name_list = [x.split('.h5ad')[0] for x in latent_file_name_list if 'correcting-donor-region_n-layers-2' in x]
latent_file_name_list
```

Example 15 (unknown):
```unknown
['Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor_correcting-donor-region_n-layers-2']
```

Example 16 (python):
```python
for latent_file_name in latent_file_name_list:
    latent_space_condition = latent_file_name.split('subsampled-per-cellstate-donor_')[1]
    latent = sc.read_h5ad(f'/nfs/team205/heart/anndata_objects/Foetal/scVI/latent_variables/{latent_file_name}.h5ad')
    # add latent space
    adata.obsm[f'scVI_latent_{latent_space_condition}']=latent.X.copy()
```

Example 17 (unknown):
```unknown
AnnData object with n_obs × n_vars = 83477 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'euploid_or_t21', 'donor_type', 'region_finest', 'flushed', 'scrublet_leiden', 'cluster_scrublet_score', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'celltypist_fine', 'conf_score_fine', 'coarse_grain_merged', 'fine_grain_merged'
    var: 'gene_id', 'gene_name_scRNA-0-0', 'feature_type-1', 'ambient_expression-0-1', 'ambient_expression-1-1', 'ambient_expression-10-1', 'ambient_expression-11-1', 'ambient_expression-12-1', 'ambient_expression-13-1', 'ambient_expression-14-1', 'ambient_expression-2-1', 'ambient_expression-3-1', 'ambient_expression-4-1', 'ambient_expression-5-1', 'ambient_expression-6-1', 'ambient_expression-7-1', 'ambient_expression-8-1', 'ambient_expression-9-1', 'mt-1', 'ribo-1', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding', 'scVI_latent_correcting-donor-region_n-layers-2'
```

Example 18 (python):
```python
for latent_file_name in latent_file_name_list:
    latent_space_condition = latent_file_name.split('subsampled-per-cellstate-donor_')[1]
    print(f'##### {latent_space_condition} #####')
    sc.pp.neighbors(adata, use_rep=f'scVI_latent_{latent_space_condition}',n_neighbors=15,key_added=latent_space_condition)
    sc.tl.umap(adata, min_dist=0.2, spread=1.0, neighbors_key=latent_space_condition)# 
    adata.obsm[f'X_umap_{latent_space_condition}'] = adata.obsm[f'X_umap'].copy()
    del adata.obsm[f'X_umap']
    # check batches
    sc.pl.embedding(adata, basis=f'umap_{latent_space_condition}',
                    color=['total_counts','pct_counts_mt','pct_counts_ribo','donor','euploid_or_t21'], 
               size=5, wspace=0.3, ncols=6, components='all',cmap='RdPu')
    print('')
    print('')
```

Example 19 (unknown):
```unknown
##### correcting-donor-region_n-layers-2 #####
```

Example 20 (unknown):
```unknown
f'umap_{latent_space_condition}'
```

Example 21 (unknown):
```unknown
'umap_correcting-donor-region_n-layers-2'
```

Example 22 (unknown):
```unknown
basis = 'umap_correcting-donor-region_n-layers-2'
```

Example 23 (python):
```python
set(adata.obs['coarse_grain_merged'])
```

Example 24 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Leukocytes',
 'Mesenchymal',
 'Neural'}
```

Example 25 (python):
```python
sc.pl.embedding(adata, basis=basis, color=['euploid_or_t21'], 
               size=5, wspace=0.3, ncols=6, components='all',cmap='RdPu')
sc.pl.embedding(adata, basis=basis, color=['coarse_grain_merged'], 
               size=5, wspace=0.3, ncols=6, components='all',cmap='RdPu')
sc.pl.embedding(adata, basis=basis, color=['mid_grain'], 
               size=5, wspace=0.3, ncols=6, components='all',cmap='RdPu')
sc.pl.embedding(adata, basis=basis, color=['mid_grain'], groups='EndocardialCells', 
               size=5, wspace=0.3, ncols=6, components='all',cmap='RdPu')
```

Example 26 (python):
```python
group_col = 'fine_grain_merged'
groups_to_plot = ['VentricularCardiomyocytesLeftCompact','VentricularCardiomyocytesLeftTrabeculated',
             'VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesRightTrabeculated']

ncols = 6
if len(groups_to_plot)%ncols==0:
    nrows = len(groups_to_plot)//ncols
else:
    nrows = len(groups_to_plot)//ncols+1

if len(groups_to_plot)<ncols:
    fig_width = len(groups_to_plot)%ncols
else:
    fig_width = ncols
    
fig,axs=plt.subplots(nrows=nrows,ncols=ncols,figsize=(fig_width*5,nrows*4))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    # ad = adata.copy()
    # update colors
    # get color in adata
    # ind = list(ad.obs[group_col].cat.categories).index(celltype)
    # ad.uns[group_col][ind] = 'darkred'
    
    # title
    middle_ind = round(len(grp)/2)
    grp_title = f'{grp[:middle_ind]}\n{grp[middle_ind:]}'
    # plot
    sc.pl.embedding(adata, basis=basis,
                  color=group_col, groups=grp,
                  size=10,legend_loc=None,
                  frameon=False,title=grp_title,
                  show=False, ax=axs_flat[i],
                 )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 27 (python):
```python
# save
adata.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor.h5ad')
```

Example 28 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/Euploid_T21Hearts_Aug2024_sel_subsampled-per-cellstate-donor.h5ad')
print(adata.X.data[:5])
basis = 'umap_correcting-donor-region_n-layers-2'
adata
```

Example 29 (unknown):
```unknown
[1. 1. 2. 1. 2.]
```

Example 30 (python):
```python
AnnData object with n_obs × n_vars = 83477 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'euploid_or_t21', 'donor_type', 'region_finest', 'flushed', 'scrublet_leiden', 'cluster_scrublet_score', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'celltypist_fine', 'conf_score_fine', 'coarse_grain_merged', 'fine_grain_merged', 'nhood_ixs_random', 'nhood_ixs_refined', 'nhood_kth_distance'
    var: 'gene_id', 'gene_name_scRNA-0-0', 'feature_type-1', 'mt-1', 'ribo-1', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'gene_name_GenomicFeatures', 'gene_biotype_GenomicFeatures', 'gene_seq_start_GenomicFeatures', 'gene_seq_end_GenomicFeatures', 'seq_name_GenomicFeatures', 'seq_strand_GenomicFeatures', 'seq_coord_system_GenomicFeatures', 'description_GenomicFeatures', 'gene_id_version_GenomicFeatures', 'canonical_transcript_GenomicFeatures', 'gene_name'
    uns: 'coarse_grain_merged_colors', 'correcting-donor-region_n-layers-2', 'donor_colors', 'euploid_or_t21_colors', 'fine_grain_merged_colors', 'mid_grain_colors', 'nhood_adata', 'nhood_neighbors_key', 'region_colors', 'scVI_latent_correcting-donor-region_n-layers-2-forMilo', 'umap'
    obsm: 'X_umap_correcting-donor-region_n-layers-2', 'latent_gene_encoding', 'nhoods', 'scVI_latent_correcting-donor-region_n-layers-2'
    obsp: 'correcting-donor-region_n-layers-2_connectivities', 'correcting-donor-region_n-layers-2_distances', 'scVI_latent_correcting-donor-region_n-layers-2-forMilo_connectivities', 'scVI_latent_correcting-donor-region_n-layers-2-forMilo_distances'
```

Example 31 (python):
```python
group_col = 'euploid_or_t21'
groups_to_plot = ['euploid',
 'tri21',
                 ]

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,7))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata, basis=basis, color=[group_col], groups=grp, 
               size=3, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
plt.savefig(f'{figdir}/Tri21_RNA_UMAP_eup-t21-separated.pdf', bbox_inches="tight",dpi=300)
```

Example 32 (python):
```python
sc.pl.embedding(adata, basis=basis, color=['mid_grain'], frameon=False, show=False, title='mid_grain (euploid)')
plt.savefig(f'{figdir}/Tri21_RNA_UMAP_midgrain.pdf', bbox_inches="tight",dpi=300)
```

Example 33 (python):
```python
sc.pl.embedding(adata, basis=basis, color=['fine_grain_merged'], frameon=False, show=False)
plt.savefig(f'{figdir}/Tri21_RNA_UMAP_finegrain.pdf', bbox_inches="tight",dpi=300)
```

Example 34 (python):
```python
sc.pl.embedding(adata, basis=basis, color=['coarse_grain_merged'], frameon=False, show=False)
plt.savefig(f'{figdir}/Tri21_RNA_UMAP_coarsegrain.pdf', bbox_inches="tight",dpi=300)
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/No1_global_prepare-for-scVI.html

**Contents:**
- Import modules¶
- Read in data¶
- Concatenate data¶
- Pre-process¶
- Set batch_key¶
- hvg identification¶
- Save¶

**Examples:**

Example 1 (python):
```python
import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import seaborn as sns
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
-----
numpy               1.20.1
pandas              1.1.4
scanpy              1.7.1
seaborn             0.11.1
session_info        1.0.0
-----
```

Example 4 (python):
```python
PIL                 8.1.2
anndata             0.7.5
anyio               NA
attr                20.3.0
babel               2.9.0
backcall            0.2.0
brotli              NA
cairo               1.20.0
certifi             2020.12.05
cffi                1.14.5
chardet             4.0.0
cloudpickle         1.6.0
colorama            0.4.4
cycler              0.10.0
cython_runtime      NA
cytoolz             0.11.0
dask                2021.03.1
dateutil            2.8.1
decorator           4.4.2
fsspec              0.8.7
get_version         2.1
google              NA
h5py                2.10.0
idna                2.10
igraph              0.8.3
ipykernel           5.5.0
ipython_genutils    0.2.0
ipywidgets          7.6.3
jedi                0.18.0
jinja2              2.11.3
joblib              1.0.1
json5               NA
jsonschema          3.2.0
jupyter_server      1.4.1
jupyterlab_server   2.3.0
kiwisolver          1.3.1
legacy_api_wrap     0.0.0
leidenalg           0.8.3
llvmlite            0.34.0
louvain             0.7.0
markupsafe          1.1.1
matplotlib          3.3.4
mpl_toolkits        NA
natsort             7.1.1
nbclassic           NA
nbformat            5.1.2
numba               0.51.2
numexpr             2.7.3
packaging           20.9
parso               0.8.1
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
prometheus_client   NA
prompt_toolkit      3.0.16
psutil              5.8.0
ptyprocess          0.7.0
pvectorc            NA
pyarrow             0.16.0
pygments            2.8.0
pyparsing           2.4.7
pyrsistent          NA
pytoml              NA
pytz                2021.1
requests            2.25.1
ruamel              NA
scipy               1.6.1
send2trash          NA
setuptools_scm      NA
simplejson          3.17.2
sinfo               0.3.1
six                 1.15.0
sklearn             0.22
sniffio             1.2.0
socks               1.7.1
sphinxcontrib       NA
statsmodels         0.12.2
storemagic          NA
tables              3.6.1
tblib               1.7.0
texttable           1.6.3
tlz                 0.11.0
toolz               0.11.1
tornado             6.1
traitlets           5.0.5
typing_extensions   NA
uritemplate         3.0.1
urllib3             1.26.3
wcwidth             0.2.5
yaml                5.1.2
zmq                 22.0.3
```

Example 5 (unknown):
```unknown
-----
IPython             7.21.0
jupyter_client      6.1.11
jupyter_core        4.7.1
jupyterlab          3.0.9
notebook            6.2.0
-----
Python 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:22:27) [GCC 9.3.0]
Linux-4.15.0-112-generic-x86_64-with-glibc2.10
-----
Session information updated at 2023-02-08 22:51
```

Example 6 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=80, facecolor='white', color_map = 'RdPu',)
```

Example 7 (python):
```python
cell = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/QC/scRNA_foetal.h5ad')

# tidy up .var
cell.var=cell.var[['gene_name']]
cell.var.rename(columns={'gene_name':'gene_name_scRNA'},inplace=True)

# add some columns
cell.obs['donor_by_library-prep'] = cell.obs['donor'].copy()
cell.obs['multiplexed'] = 'No'

cell
```

Example 8 (unknown):
```unknown
AnnData object with n_obs × n_vars = 100463 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed'
    var: 'gene_name_scRNA'
    uns: 'sangerID_colors'
    obsm: 'latent_gene_encoding'
```

Example 9 (python):
```python
multi = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/QC/multiome_RNA_foetal.h5ad')

# tidy up .var
multi.var=multi.var[['gene_name']]
multi.var.rename(columns={'gene_name':'gene_name_multiome'},inplace=True)

multi
```

Example 10 (unknown):
```unknown
AnnData object with n_obs × n_vars = 272338 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet'
    var: 'gene_name_multiome'
    uns: 'sangerID_colors'
    obsm: 'latent_gene_encoding'
```

Example 11 (python):
```python
adata = cell.concatenate(multi, join='inner', batch_key=None, index_unique=None)
adata
```

Example 12 (unknown):
```unknown
AnnData object with n_obs × n_vars = 372801 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1'
    obsm: 'latent_gene_encoding'
```

Example 13 (python):
```python
adata.obs['donor'].value_counts()
```

Example 14 (unknown):
```unknown
Hst41      129909
Hst33       62684
Hst39       30591
C99         17921
C97         17388
C92         15379
C94         13971
Hst40       11559
BRC2251      9651
BRC2256      8525
BRC2260      8408
Hst36        7848
BRC2252      7366
C86          6567
BRC2263      5917
BRC2262      4749
C87          4499
C104         3411
C98          3039
C85          2808
C82           611
Name: donor, dtype: int64
```

Example 15 (python):
```python
pd.crosstab(adata.obs['facility'],adata.obs['kit_10x'])
```

Example 16 (python):
```python
# save
adata.write('/nfs/team205/heart/anndata_objects/Foetal/RNA_foetal_raw.h5ad')
```

Example 17 (unknown):
```unknown
... storing 'sangerID' as categorical
... storing 'combinedID' as categorical
... storing 'donor' as categorical
... storing 'region' as categorical
... storing 'region_finest' as categorical
... storing 'age' as categorical
... storing 'gender' as categorical
... storing 'facility' as categorical
... storing 'cell_or_nuclei' as categorical
... storing 'modality' as categorical
... storing 'kit_10x' as categorical
... storing 'scrublet_leiden' as categorical
... storing 'donor_by_library-prep' as categorical
... storing 'multiplexed' as categorical
... storing 'SOC | status' as categorical
```

Example 18 (python):
```python
adata.X.data[:10]
```

Example 19 (unknown):
```unknown
array([ 1.,  1.,  5.,  5.,  8.,  4., 13.,  4.,  3.,  1.], dtype=float32)
```

Example 20 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# filter genes
sc.pp.filter_genes(adata, min_cells=3)

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

adata.shape
```

Example 21 (unknown):
```unknown
filtered out 1675 genes that are detected in less than 3 cells
normalizing counts per cell
    finished (0:00:03)
```

Example 22 (unknown):
```unknown
(372801, 34926)
```

Example 23 (python):
```python
# combining Donor, Cell_or_Nuclei, and Kit_10X
adata.obs['batch_key']=adata.obs['donor'].astype('str')+'_'+adata.obs['cell_or_nuclei'].astype('str')+'_'+adata.obs['kit_10x'].astype('str')
adata.obs['batch_key'].value_counts()
```

Example 24 (unknown):
```unknown
Hst41_Nuclei_Multiome-v1    129909
Hst33_Nuclei_Multiome-v1     62684
Hst39_Nuclei_Multiome-v1     30591
C99_Cell_5prime-v2           17921
C97_Cell_5prime-v2           17388
C92_Nuclei_Multiome-v1       15379
C94_Cell_5prime-v2           13971
Hst40_Nuclei_Multiome-v1     11559
BRC2251_Cell_3prime-v3        9651
BRC2256_Cell_3prime-v3        8525
BRC2260_Cell_3prime-v3        8408
Hst36_Nuclei_Multiome-v1      7848
BRC2252_Cell_3prime-v3        7366
C86_Cell_5prime-v2            6567
BRC2263_Cell_3prime-v3        5917
BRC2262_Cell_3prime-v3        4749
C87_Nuclei_Multiome-v1        4499
C104_Nuclei_Multiome-v1       3411
C98_Nuclei_Multiome-v1        3039
C85_Nuclei_Multiome-v1        2808
C82_Nuclei_Multiome-v1         611
Name: batch_key, dtype: int64
```

Example 25 (python):
```python
sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)
```

Example 26 (python):
```python
extracting highly variable genes
... storing 'batch_key' as categorical
    finished (0:00:49)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
```

Example 27 (python):
```python
# freeze the state in `.raw`
adata.raw = adata
```

Example 28 (python):
```python
# subset hvgs
adata = adata[:, adata.var.highly_variable]
```

Example 29 (python):
```python
adata.write('/nfs/team205/heart/anndata_objects/Foetal/scVI/RNA_foetal_pp.h5ad') # batch_key: Donor, Cell_or_Nuclei, and Kit_10X
adata
```

Example 30 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 372801 × 3343
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'log1p', 'hvg'
    obsm: 'latent_gene_encoding'
    layers: 'counts'
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Cardiomyocytes/CardiomyocyteLVRVAtriaTrabeculatedFigures.html

**Contents:**
- Subcluster¶
- Compact trabeculated GO¶
- Analysis on ratios¶
- Any markers of cycling CMs (apart from cycling genes)¶
- If you wish to investigate from the global object¶
- Fetal CMs only, for UMAP figure¶

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-09-18 10:12.
```

Example 5 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(297473, 36601)
```

Example 7 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 8 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 9 (python):
```python
#Expression: "YlGn" (e.g. DE plots)
#Divergent expression: "PRGn" (e.g. log2FC)
#Age: "afmhot_r"
#Others: "viridis" (e.g. UMAP expression)

#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodePacemakerCells':'#854834',
    'AtrioventricularNodePacemakerCells':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParasympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 10 (python):
```python
# Adding hierarchy to the fine_grain mid_grain and coarse_grain; this will be propagated when plotting
coarsegrain_order = ['Cardiomyocytes',
                     'Mesenchymal',
                     'Endothelium',
                     'Epicardium',
                     'Neural',
                     'Leukocytes']

midgrain_order = ['AtrialCardiomyocytes',
                'VentricularCardiomyocytes', 
                'CardiacConductionSystem', 
                  
                'Fibroblasts',
                 'MuralCells',
                  'PericardialCells',
                  
                'BloodVesselEndothelialCells',
                'EndocardialCells',
                  'LymphaticEndothelialCells',
                    
                  'EpicardialCells',
                  
                  'Neurons',
                 'Glia',
              
                    'MyeloidCells',  
                 'LymphoidCells',
                ]

finegrain_order = [ 'AtrialCardiomyocytesLeft',
                    'AtrialCardiomyocytesRight',
                   'AtrialCardiomyocytesCycling',
                     
                     'VentricularCardiomyocytesLeftCompact',
                     'VentricularCardiomyocytesRightCompact',
                   'VentricularCardiomyocytesLeftTrabeculated',
                     'VentricularCardiomyocytesRightTrabeculated',
                   'VentricularCardiomyocytesCycling',
                   
                   'SinoatrialNodePacemakerCells',
                   'AtrioventricularNodePacemakerCells',
                     'VentricularConductionSystemProximal',
                     'VentricularConductionSystemDistal',
                     
                    'GreatVesselAdventitialFibroblasts',
                   'CoronaryVesselAdventitialFibroblasts',
                 'MyocardialInterstitialFibroblasts',
                 'SubEpicardialFibroblasts',
                 'Myofibroblasts',
                    'LymphNodeFibroblasticReticularCells',
                        'ValveInterstitialCells',
               
                   'GreatVesselSmoothMuscleCells',
                 'CoronarySmoothMuscleCells',
                 'DuctusArteriosusSmoothMuscleCells',
                   'CoronaryPericytes',
                   
                   'PericardialCellsIntermediate', 
                   'PericardialCellsFibrous', 
                   'PericardialCellsParietal',
                   
                   'GreatVesselArterialEndothelialCells',
                     'GreatVesselVenousEndothelialCells',
                  'CoronaryArterialEndothelialCells',
                     'CoronaryVenousEndothelialCells',
                   'CoronaryCapillaryEndothelialCells',
 
                  'EndocardialCells',
                   'EndocardialCushionCells',
                   'ValveEndothelialCells',
                  
                'LymphaticEndothelialCells',
                
                'MesothelialEpicardialCells',
                   'EpicardiumDerivedCells', 
                  
                   'NeuronPrecursors',
                    'ChromaffinCells',
                     'SympatheticNeurons',
                     'ParasympatheticNeurons',
                     
                  'SchwannCellPrecursors', 
                   'SchwannCells',
                  
                   'MonocytesMPOpos',
                   'Monocytes',
                   'MonocyteDerivedCells',
                   'MacrophagesCX3CR1pos',
                   'MacrophagesTIMD4pos',
                    'MacrophagesLYVE1pos',
                   'MacrophagesATF3pos',
                    'DendriticCellsType1',
                  'DendriticCellsMature',
                   'PlasmacytoidDendriticCells',
                   'MastCells',
                 'Megakaryocytes',

                   'TCellsCD4pos',
                 'TCellsCD8pos',
                 'TregsCD4pos',
                   'ProBCells',
                   'BCells',
                 'BCellsMS4A1pos',
                   'NaturalKillerCells',
                 'InnateLymphoidCells',
                ]

adata.obs['coarse_grain'].cat.reorder_categories(coarsegrain_order,inplace=True)
adata.obs['mid_grain'].cat.reorder_categories(midgrain_order,inplace=True)
adata.obs['fine_grain'].cat.reorder_categories(finegrain_order,inplace=True)

sc.pl.umap(adata, color='coarse_grain')
sc.pl.umap(adata, color='mid_grain')
sc.pl.umap(adata, color='fine_grain')
```

Example 11 (python):
```python
set(adata.obs.fine_grain)
```

Example 12 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 13 (python):
```python
set(adata.obs.mid_grain)
```

Example 14 (unknown):
```unknown
{'AtrialCardiomyocytes',
 'BloodVesselEndothelialCells',
 'CardiacConductionSystem',
 'EndocardialCells',
 'EpicardialCells',
 'Fibroblasts',
 'Glia',
 'LymphaticEndothelialCells',
 'LymphoidCells',
 'MuralCells',
 'MyeloidCells',
 'Neurons',
 'PericardialCells',
 'VentricularCardiomyocytes'}
```

Example 15 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryPericytes','CoronarySmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','GreatVesselSmoothMuscleCells'])].copy()
#adata = adata[adata.obs['mid_grain'].isin(['CardiacConductionSystem'])].copy()
adata=adata[adata.obs.coarse_grain=='Cardiomyocytes',:].copy()
```

Example 16 (unknown):
```unknown
AnnData object with n_obs × n_vars = 5087 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 17 (python):
```python
adata = adata[adata.obs['donor'].isin(['BRC2251','BRC2253','BRC2256','BRC2260','BRC2262','BRC2263'])].copy()
```

Example 18 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['VentricularConductionSystemProximal','VentricularConductionSystemDistal','VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesLeftCompact'])].copy()
```

Example 19 (python):
```python
set(adata.obs.fine_grain)
```

Example 20 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'SinoatrialNodePacemakerCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 21 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 22 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:09)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1125
```

Example 23 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'CCNE2', 'UBR7', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    205 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    41 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 24 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 25 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [01:48<00:00,  2.17s/it, loss=581, v_num=1]
```

Example 26 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'ZFP36', 'SOCS3', 'CEBPB', 'EGR1', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1', 'BTG2', 'DUSP1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    272 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBB', 'HBD', 'HBE1', 'HBZ', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    184 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:04)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:08)
```

Example 27 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 28 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 29 (python):
```python
sc.pl.umap(adata, color=['PRRX1','fine_grain'])
```

Example 30 (python):
```python
#adata.write('./29MarchVentricularCMs.h5ad')
#adata.write('./29MarchAtrialCMs.h5ad')
#adata.write('./11MayAllCMs.h5ad')
#adata.write('./29MarchCardiacConductionSystem.h5ad')
```

Example 31 (python):
```python
adata=sc.read('./11MayAllCMs.h5ad')
print(adata.shape)
```

Example 32 (unknown):
```unknown
(74884, 1821)
```

Example 33 (python):
```python
adata=adata[adata.obs.cycling=='no',:].copy()
```

Example 34 (python):
```python
sc.pl.umap(adata, color='mid_grain')
```

Example 35 (python):
```python
#Getting the UMAPs for clusterofinterest
ClusterOfInterest='VentricularCardiomyocytes'
sc.tl.rank_genes_groups(adata, 'mid_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='YlGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 36 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
```

Example 37 (python):
```python
adata=adata[adata.obs.cycling=='no',:].copy()
adata=adata[adata.obs.mid_grain=='VentricularCardiomyocytes',:].copy()
```

Example 38 (python):
```python
Genes=['SLC1A3','ADGRL2','MGAT4C','CDH13','CRIM1','ANKRD1','MYL2','PRRX1','GPNMB','ZNF385D','RABGAP1L','CPVL','SYNDIG1','ADCY5','SEMA5A','ADAMTSL1','SGCD','MYOM2','SPOCK1','SLIT3','TBX20','KCNQ5','HEY2','LRMDA','BRINP3','CSMD1','CRNDE','OPCML','CYP2J2','CNN1','NPPB','XIRP2','NCALD','ENOX1','KCNIP4','SORCS3']
print(set([x for x in Genes if Genes.count(x) > 1]))
sc.pl.dotplot(adata,Genes,groupby='fine_grain',var_group_positions=[(0,4),(5,9),(10,12),(13,19)], var_group_labels=['left','right','compact','trabeculated'],standard_scale='var',cmap='YlGn',var_group_rotation=0)
```

Example 39 (python):
```python
#VCMs all
bdata=adata[adata.obs.mid_grain=='VentricularCardiomyocytes',:].copy()
Genes=['TBX20','KCNQ5','HEY2','LRMDA','BRINP3','CSMD1','CRNDE','OPCML','CYP2J2','CNN1','NPPB','XIRP2','NCALD','ENOX1','KCNIP4','SORCS3']
print(set([x for x in Genes if Genes.count(x) > 1]))
sc.pl.dotplot(bdata,Genes,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 40 (python):
```python
#VCMs right/left and traveculated/compact
bdata=adata[adata.obs.mid_grain=='VentricularCardiomyocytes',:].copy()
Genes=['RABGAP1L','CPVL','SYNDIG1','ADCY5','SEMA5A','ADAMTSL1','SGCD','MYOM2','SPOCK1','SLIT3']
print(set([x for x in Genes if Genes.count(x) > 1]))
sc.pl.dotplot(bdata, Genes,var_group_positions=[(0,2),(3,9)], var_group_labels=['compact','trabeculated'], var_group_rotation=0 ,groupby='fine_grain',standard_scale='var',cmap='YlGn')
Genes= ['SLC1A3','ADGRL2','MGAT4C','CDH13','CRIM1','ANKRD1','MYL2','PRRX1','GPNMB','ZNF385D']
print(set([x for x in Genes if Genes.count(x) > 1]))
sc.pl.dotplot(bdata,Genes ,var_group_positions=[(0,4),(5,9)], var_group_labels=['left','right'], var_group_rotation=0, groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 41 (python):
```python
#ACMs
bdata=adata[adata.obs.mid_grain=='AtrialCardiomyocytes',:].copy()
Genes=['KCNMB2','PCDH7','RYR3','PANCR','MBP','NAV3','PITX2','NTM','ROR1','KIF26B','PLCL1','ANGPT1','BRINP3','BMP10']
print(set([x for x in Genes if Genes.count(x) > 1]))
sc.pl.dotplot(bdata, Genes ,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 42 (python):
```python
#CardiacConductionSystem
bdata=adata[adata.obs.mid_grain=='CardiacConductionSystem',:].copy()
Genes=['MYH6','CACNA1D','KCNJ3','NR2F2','NRXN1','CAMK1D','HCN1','TBX3','SHOX2','PDE1A','TENM4','MYH11','TBX18','GREB1L','GNG11','NRXN3','RSPO3','ZNF536','MYH7','MYL2','NAV1','ADAMTSL1','GJA1','GCNT2','LPL','PCDH7','PRDM16','NIBAN1','PHACTR1','FGF18','OPCML','NTN1','IRX3','IRX2','DGKG']
print(set([x for x in Genes if Genes.count(x) > 1]))
sc.pl.dotplot(bdata, Genes,categories_order=['SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells','VentricularConductionSystemProximal','VentricularConductionSystemDistal'], var_group_positions=[(0,17),(18,34)], var_group_labels=['atrial conduction','ventricular conduction'], var_group_rotation=0,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 43 (python):
```python
#!!No good markres of conduction system

#Getting the UMAPs for clusterofinterest
ClusterOfInterest='CardiacConductionSystem'
sc.tl.rank_genes_groups(adata, 'mid_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain', categories_order=['SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells','VentricularConductionSystemProximal','VentricularConductionSystemDistal','AtrialCardiomyocytesLeft','AtrialCardiomyocytesRight','VentricularCardiomyocytesLeftCompact','VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesRightTrabeculated'],standard_scale='var',cmap='YlGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 44 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
```

Example 45 (python):
```python
sc.pl.dotplot(adata, ['CNTN2','NPTN','NTM'] ,groupby='fine_grain', categories_order=['SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells','VentricularConductionSystemProximal','VentricularConductionSystemDistal','AtrialCardiomyocytesLeft','AtrialCardiomyocytesRight','VentricularCardiomyocytesLeftCompact','VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesRightTrabeculated'],standard_scale='var',cmap='YlGn')
```

Example 46 (python):
```python
adata = adata[adata.obs['mid_grain'].isin(['VentricularCardiomyocytes'])].copy()
adata = adata[adata.obs['cycling'].isin(['no'])].copy()
```

Example 47 (python):
```python
adata.obs['type']= 'compact'
adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightTrabeculated']]]='trabeculated'
sc.pl.umap(adata, color='type')
```

Example 48 (unknown):
```unknown
... storing 'type' as categorical
```

Example 49 (python):
```python
#This box to run enrichment right away
sc.tl.rank_genes_groups(adata, 'type', method='t-test', key_added = "t-test")
gene_set_names = gseapy.get_library_name(organism='Human')
print(gene_set_names)
glist = sc.get.rank_genes_groups_df(adata, group='trabeculated', 
                                    key='t-test', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
enr_res.results.head(20)
gseapy.barplot(enr_res.res2d,title='GO_Biological_Process_2021',top_term=20,figsize=(3,20))
```

Example 50 (python):
```python
ranking genes
    finished: added to `.uns['wilcoxon']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:32)
['ARCHS4_Cell-lines', 'ARCHS4_IDG_Coexp', 'ARCHS4_Kinases_Coexp', 'ARCHS4_TFs_Coexp', 'ARCHS4_Tissues', 'Achilles_fitness_decrease', 'Achilles_fitness_increase', 'Aging_Perturbations_from_GEO_down', 'Aging_Perturbations_from_GEO_up', 'Allen_Brain_Atlas_10x_scRNA_2021', 'Allen_Brain_Atlas_down', 'Allen_Brain_Atlas_up', 'Azimuth_Cell_Types_2021', 'BioCarta_2013', 'BioCarta_2015', 'BioCarta_2016', 'BioPlanet_2019', 'BioPlex_2017', 'CCLE_Proteomics_2020', 'CORUM', 'COVID-19_Related_Gene_Sets', 'COVID-19_Related_Gene_Sets_2021', 'Cancer_Cell_Line_Encyclopedia', 'CellMarker_Augmented_2021', 'ChEA_2013', 'ChEA_2015', 'ChEA_2016', 'ChEA_2022', 'Chromosome_Location', 'Chromosome_Location_hg19', 'ClinVar_2019', 'DSigDB', 'Data_Acquisition_Method_Most_Popular_Genes', 'DepMap_WG_CRISPR_Screens_Broad_CellLines_2019', 'DepMap_WG_CRISPR_Screens_Sanger_CellLines_2019', 'Descartes_Cell_Types_and_Tissue_2021', 'Diabetes_Perturbations_GEO_2022', 'DisGeNET', 'Disease_Perturbations_from_GEO_down', 'Disease_Perturbations_from_GEO_up', 'Disease_Signatures_from_GEO_down_2014', 'Disease_Signatures_from_GEO_up_2014', 'DrugMatrix', 'Drug_Perturbations_from_GEO_2014', 'Drug_Perturbations_from_GEO_down', 'Drug_Perturbations_from_GEO_up', 'ENCODE_Histone_Modifications_2013', 'ENCODE_Histone_Modifications_2015', 'ENCODE_TF_ChIP-seq_2014', 'ENCODE_TF_ChIP-seq_2015', 'ENCODE_and_ChEA_Consensus_TFs_from_ChIP-X', 'ESCAPE', 'Elsevier_Pathway_Collection', 'Enrichr_Libraries_Most_Popular_Genes', 'Enrichr_Submissions_TF-Gene_Coocurrence', 'Enrichr_Users_Contributed_Lists_2020', 'Epigenomics_Roadmap_HM_ChIP-seq', 'FANTOM6_lncRNA_KD_DEGs', 'GO_Biological_Process_2013', 'GO_Biological_Process_2015', 'GO_Biological_Process_2017', 'GO_Biological_Process_2017b', 'GO_Biological_Process_2018', 'GO_Biological_Process_2021', 'GO_Cellular_Component_2013', 'GO_Cellular_Component_2015', 'GO_Cellular_Component_2017', 'GO_Cellular_Component_2017b', 'GO_Cellular_Component_2018', 'GO_Cellular_Component_2021', 'GO_Molecular_Function_2013', 'GO_Molecular_Function_2015', 'GO_Molecular_Function_2017', 'GO_Molecular_Function_2017b', 'GO_Molecular_Function_2018', 'GO_Molecular_Function_2021', 'GTEx_Aging_Signatures_2021', 'GTEx_Tissue_Expression_Down', 'GTEx_Tissue_Expression_Up', 'GTEx_Tissues_V8_2023', 'GWAS_Catalog_2019', 'GeneSigDB', 'Gene_Perturbations_from_GEO_down', 'Gene_Perturbations_from_GEO_up', 'Genes_Associated_with_NIH_Grants', 'Genome_Browser_PWMs', 'GlyGen_Glycosylated_Proteins_2022', 'HDSigDB_Human_2021', 'HDSigDB_Mouse_2021', 'HMDB_Metabolites', 'HMS_LINCS_KinomeScan', 'HomoloGene', 'HuBMAP_ASCT_plus_B_augmented_w_RNAseq_Coexpression', 'HuBMAP_ASCTplusB_augmented_2022', 'HumanCyc_2015', 'HumanCyc_2016', 'Human_Gene_Atlas', 'Human_Phenotype_Ontology', 'IDG_Drug_Targets_2022', 'InterPro_Domains_2019', 'Jensen_COMPARTMENTS', 'Jensen_DISEASES', 'Jensen_TISSUES', 'KEA_2013', 'KEA_2015', 'KEGG_2013', 'KEGG_2015', 'KEGG_2016', 'KEGG_2019_Human', 'KEGG_2019_Mouse', 'KEGG_2021_Human', 'KOMP2_Mouse_Phenotypes_2022', 'Kinase_Perturbations_from_GEO_down', 'Kinase_Perturbations_from_GEO_up', 'L1000_Kinase_and_GPCR_Perturbations_down', 'L1000_Kinase_and_GPCR_Perturbations_up', 'LINCS_L1000_CRISPR_KO_Consensus_Sigs', 'LINCS_L1000_Chem_Pert_Consensus_Sigs', 'LINCS_L1000_Chem_Pert_down', 'LINCS_L1000_Chem_Pert_up', 'LINCS_L1000_Ligand_Perturbations_down', 'LINCS_L1000_Ligand_Perturbations_up', 'Ligand_Perturbations_from_GEO_down', 'Ligand_Perturbations_from_GEO_up', 'MAGMA_Drugs_and_Diseases', 'MCF7_Perturbations_from_GEO_down', 'MCF7_Perturbations_from_GEO_up', 'MGI_Mammalian_Phenotype_2013', 'MGI_Mammalian_Phenotype_2017', 'MGI_Mammalian_Phenotype_Level_3', 'MGI_Mammalian_Phenotype_Level_4', 'MGI_Mammalian_Phenotype_Level_4_2019', 'MGI_Mammalian_Phenotype_Level_4_2021', 'MSigDB_Computational', 'MSigDB_Hallmark_2020', 'MSigDB_Oncogenic_Signatures', 'Metabolomics_Workbench_Metabolites_2022', 'Microbe_Perturbations_from_GEO_down', 'Microbe_Perturbations_from_GEO_up', 'Mouse_Gene_Atlas', 'NCI-60_Cancer_Cell_Lines', 'NCI-Nature_2015', 'NCI-Nature_2016', 'NIH_Funded_PIs_2017_AutoRIF_ARCHS4_Predictions', 'NIH_Funded_PIs_2017_GeneRIF_ARCHS4_Predictions', 'NIH_Funded_PIs_2017_Human_AutoRIF', 'NIH_Funded_PIs_2017_Human_GeneRIF', 'NURSA_Human_Endogenous_Complexome', 'OMIM_Disease', 'OMIM_Expanded', 'Old_CMAP_down', 'Old_CMAP_up', 'Orphanet_Augmented_2021', 'PFOCR_Pathways', 'PPI_Hub_Proteins', 'PanglaoDB_Augmented_2021', 'Panther_2015', 'Panther_2016', 'Pfam_Domains_2019', 'Pfam_InterPro_Domains', 'PheWeb_2019', 'PhenGenI_Association_2021', 'Phosphatase_Substrates_from_DEPOD', 'ProteomicsDB_2020', 'Proteomics_Drug_Atlas_2023', 'RNA-Seq_Disease_Gene_and_Drug_Signatures_from_GEO', 'RNAseq_Automatic_GEO_Signatures_Human_Down', 'RNAseq_Automatic_GEO_Signatures_Human_Up', 'RNAseq_Automatic_GEO_Signatures_Mouse_Down', 'RNAseq_Automatic_GEO_Signatures_Mouse_Up', 'Rare_Diseases_AutoRIF_ARCHS4_Predictions', 'Rare_Diseases_AutoRIF_Gene_Lists', 'Rare_Diseases_GeneRIF_ARCHS4_Predictions', 'Rare_Diseases_GeneRIF_Gene_Lists', 'Reactome_2013', 'Reactome_2015', 'Reactome_2016', 'Reactome_2022', 'SILAC_Phosphoproteomics', 'Serine_Threonine_Kinome_Atlas_2023', 'SubCell_BarCode', 'SynGO_2022', 'SysMyo_Muscle_Gene_Sets', 'TF-LOF_Expression_from_GEO', 'TF_Perturbations_Followed_by_Expression', 'TG_GATES_2020', 'TRANSFAC_and_JASPAR_PWMs', 'TRRUST_Transcription_Factors_2019', 'Table_Mining_of_CRISPR_Studies', 'Tabula_Muris', 'Tabula_Sapiens', 'TargetScan_microRNA', 'TargetScan_microRNA_2017', 'Tissue_Protein_Expression_from_Human_Proteome_Map', 'Tissue_Protein_Expression_from_ProteomicsDB', 'Transcription_Factor_PPIs', 'UK_Biobank_GWAS_v1', 'Virus-Host_PPI_P-HIPSTer_2020', 'VirusMINT', 'Virus_Perturbations_from_GEO_down', 'Virus_Perturbations_from_GEO_up', 'WikiPathway_2021_Human', 'WikiPathways_2013', 'WikiPathways_2015', 'WikiPathways_2016', 'WikiPathways_2019_Human', 'WikiPathways_2019_Mouse', 'dbGaP', 'huMAP', 'lncHUB_lncRNA_Co-Expression', 'miRTarBase_2017']
1134
```

Example 51 (python):
```python
sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
gseapy.barplot(enr_res.res2d,title='GO_Biological_Process_2021',top_term=20,figsize=(3,5))
```

Example 52 (python):
```python
glist = sc.get.rank_genes_groups_df(adata, group='compact', 
                                    key='wilcoxon', log2fc_min=0.25, 
                                    pval_cutoff=0.05)['names'].squeeze().str.strip().tolist()
print(len(glist))                                  
#GO_Biological_Process_2021,GO_Cellular_Component_2021,GO_Molecular_Function_2021
enr_res = gseapy.enrichr(gene_list=glist,
                     organism='Human',
                     gene_sets='GO_Biological_Process_2021',
                     cutoff = 0.5)
enr_res.results.head(20)
gseapy.barplot(enr_res.res2d,title='GO_Biological_Process_2021',top_term=20,figsize=(3,5))
```

Example 53 (python):
```python
adata=sc.read('./11MayAllCMs.h5ad')
print(adata.shape)
```

Example 54 (unknown):
```unknown
(74884, 1821)
```

Example 55 (python):
```python
plt.rcParams['figure.figsize'] = [3,2]
adata.obs['cycling2']= 'na'
adata.obs['cycling2'][[x for x in adata.obs_names if adata.obs.cycling[x] in ['no']]]='non-cycling'
adata.obs['cycling2'][[x for x in adata.obs_names if adata.obs.cycling[x] in ['yes']]]='cycling'
tmp = pd.crosstab(adata.obs['week'],adata.obs['cycling2'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('all cardiomyocytes')
plt.ylabel('proportion')
```

Example 56 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 57 (python):
```python
kdata=adata[adata.obs.mid_grain=='AtrialCardiomyocytes',:].copy()
kdata.obs['cycling2']= 'na'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['no']]]='non-cycling'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['yes']]]='cycling'

plt.rcParams['figure.figsize'] = [3,2]
tmp = pd.crosstab(kdata.obs['week'],kdata.obs['cycling2'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('atrial cardiomyocytes')
plt.ylabel('proportion')
```

Example 58 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 59 (python):
```python
kdata=adata[adata.obs.mid_grain=='VentricularCardiomyocytes',:].copy()
kdata.obs['cycling2']= 'na'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['no']]]='non-cycling'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['yes']]]='cycling'
plt.rcParams['figure.figsize'] = [3,2]
tmp = pd.crosstab(kdata.obs['week'],kdata.obs['cycling2'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('ventricular cardiomyocytes')
plt.ylabel('proportion')
```

Example 60 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 61 (python):
```python
kdata=adata[adata.obs.mid_grain=='CardiacConductionSystem',:].copy()
kdata.obs['cycling2']= 'na'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['no']]]='non-cycling'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['yes']]]='cycling'
plt.rcParams['figure.figsize'] = [3,2]
tmp = pd.crosstab(kdata.obs['week'],kdata.obs['cycling2'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('cardiac conduction system')
plt.ylabel('proportion')
```

Example 62 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 63 (python):
```python
kdata = adata[adata.obs['fine_grain'].isin(['VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftCompact'])].copy()
kdata.obs['cycling2']= 'na'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['no']]]='non-cycling'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['yes']]]='cycling'
plt.rcParams['figure.figsize'] = [3,2]
tmp = pd.crosstab(kdata.obs['week'],kdata.obs['cycling2'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('ventricular compact cardiomyocytes')
plt.ylabel('proportion')
```

Example 64 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 65 (python):
```python
kdata = adata[adata.obs['fine_grain'].isin(['VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesLeftTrabeculated'])].copy()
kdata.obs['cycling2']= 'na'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['no']]]='non-cycling'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['yes']]]='cycling'
plt.rcParams['figure.figsize'] = [3,2]
tmp = pd.crosstab(kdata.obs['week'],kdata.obs['cycling2'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('ventricular trabeculated cardiomyocytes')
plt.ylabel('proportion')
```

Example 66 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 67 (python):
```python
kdata = adata[adata.obs['fine_grain'].isin(['VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesRightCompact'])].copy()
kdata.obs['cycling2']= 'na'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['no']]]='non-cycling'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['yes']]]='cycling'
plt.rcParams['figure.figsize'] = [3,2]
tmp = pd.crosstab(kdata.obs['week'],kdata.obs['cycling2'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('right ventricular cardiomyocytes')
plt.ylabel('proportion')
```

Example 68 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 69 (python):
```python
kdata = adata[adata.obs['fine_grain'].isin(['VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesLeftCompact'])].copy()
kdata.obs['cycling2']= 'na'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['no']]]='non-cycling'
kdata.obs['cycling2'][[x for x in kdata.obs_names if kdata.obs.cycling[x] in ['yes']]]='cycling'
plt.rcParams['figure.figsize'] = [3,2]
tmp = pd.crosstab(kdata.obs['week'],kdata.obs['cycling2'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('left ventricular cardiomyocytes')
plt.ylabel('proportion')
```

Example 70 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 71 (python):
```python
kdata = adata[adata.obs['fine_grain'].isin(['VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftCompact'])].copy()
kdata.obs['compacttrabeculated']= 'na'
kdata.obs['compacttrabeculated'][[x for x in kdata.obs_names if kdata.obs.fine_grain[x] in ['VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightTrabeculated']]]='trabeculated'
kdata.obs['compacttrabeculated'][[x for x in kdata.obs_names if kdata.obs.fine_grain[x] in ['VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftCompact']]]='compact'

plt.rcParams['figure.figsize'] = [3,2]
tmp = pd.crosstab(kdata.obs['week'],kdata.obs['compacttrabeculated'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower left')
plt.title('ventricular cardiomyocytes')
plt.ylabel('proportion')
```

Example 72 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 73 (python):
```python
#Getting the UMAPs for clusterofinterest
ClusterOfInterest='yes'
#sc.tl.rank_genes_groups(adata, 'cycling', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
DEGenesForCluster=list(set(DEGenesForCluster)-set(cell_cycle_genes)-set(ribo_genes))
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='cycling',standard_scale='var',cmap='YlGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 74 (python):
```python
bdata=sc.read('./AdultAtrialCMs.h5ad')
bdata.obs['batch_key'] = bdata.obs['donor']
bdata.obs['total_counts'] = bdata.obs['n_counts']
bdata.obs['pct_counts_mt'] = bdata.obs['percent_mito']
bdata.obs['pct_counts_ribo'] = bdata.obs['percent_ribo']
print(bdata.shape)

cdata=sc.read('./AdultVentricularCMs.h5ad')
cdata.obs['batch_key'] = cdata.obs['donor']
cdata.obs['total_counts'] = cdata.obs['n_counts']
cdata.obs['pct_counts_mt'] = cdata.obs['percent_mito']
cdata.obs['pct_counts_ribo'] = cdata.obs['percent_ribo']
print(cdata.shape)

adata = adata.concatenate(bdata,cdata) 
print(adata)
del bdata
del cdata
```

Example 75 (unknown):
```unknown
(23483, 33538)
(125289, 33538)
AnnData object with n_obs × n_vars = 223656 × 31915
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'NRP', 'age_group', 'cell_source', 'cell_type', 'gender', 'percent_mito', 'percent_ribo', 'sample', 'source', 'type', 'version', 'cell_states', 'Used', 'batch'
    var: 'gene_name_scRNA-0-0', 'gene_id-0', 'gene_ids-Harvard-Nuclei-1', 'feature_types-Harvard-Nuclei-1', 'gene_ids-Sanger-Nuclei-1', 'feature_types-Sanger-Nuclei-1', 'gene_ids-Sanger-Cells-1', 'feature_types-Sanger-Cells-1', 'gene_ids-Sanger-CD45-1', 'feature_types-Sanger-CD45-1', 'gene_ids-Harvard-Nuclei-2', 'feature_types-Harvard-Nuclei-2', 'gene_ids-Sanger-Nuclei-2', 'feature_types-Sanger-Nuclei-2', 'gene_ids-Sanger-Cells-2', 'feature_types-Sanger-Cells-2', 'gene_ids-Sanger-CD45-2', 'feature_types-Sanger-CD45-2'
    obsm: 'X_umap'
```

Example 76 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 77 (unknown):
```unknown
normalizing counts per cell
    finished (0:00:01)
extracting highly variable genes
```

Example 78 (unknown):
```unknown
... storing 'donor' as categorical
... storing 'region' as categorical
... storing 'batch_key' as categorical
... storing 'cell_type' as categorical
... storing 'sample' as categorical
... storing 'cell_states' as categorical
```

Example 79 (python):
```python
finished (0:00:40)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1412
```

Example 80 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'UHRF1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    246 total control genes are used. (0:00:01)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'AURKB', 'ANP32E', 'HJURP', 'TTK', 'CDC25C', 'RANGAP1', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    599 total control genes are used. (0:00:01)
-->     'phase', cell cycle phase (adata.obs)
```

Example 81 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 82 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [14:37<00:00, 17.54s/it, loss=600, v_num=1]
```

Example 83 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPD', 'CEBPB', 'HSP90AB1', 'HSPA8', 'HSPE1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    635 total control genes are used. (0:00:01)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBE1', 'HBZ', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    245 total control genes are used. (0:00:01)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:23)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:01:27)
```

Example 84 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 85 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 86 (python):
```python
#adata.write('./29MarchAdultandFetalCMsProcessedTogether.h5ad')
```

Example 87 (python):
```python
sc.pl.umap(adata, color='fine_grain')
```

Example 88 (python):
```python
AtrialCMsleiden=['1']
VentricularCMsleiden=['0']
adata.obs['cmtype']= 'na'
adata.obs['cmtype'][[x for x in adata.obs_names if adata.obs.leiden[x] in AtrialCMsleiden]]='atrial'
adata.obs['cmtype'][[x for x in adata.obs_names if adata.obs.leiden[x] in VentricularCMsleiden]]='ventricular'
sc.pl.umap(adata, color='cmtype')

FetalDonors=['Hst41','Hst39','BRC2263','BRC2262','BRC2251','Hst33','C92','C97','C98','Hst36','C99','BRC2260','C104','BRC2256','C94','C87','BRC2253','C85','C86','Hst40','C82']
AdultDonors=['D7','D6','D2','D1','H7','H5','D3','D5','H6','H3','D11','H4','D4','H2']
adata.obs['donortype']= 'na'
adata.obs['donortype'][[x for x in adata.obs_names if adata.obs.donor[x] in FetalDonors]]='fetal'
adata.obs['donortype'][[x for x in adata.obs_names if adata.obs.donor[x] in AdultDonors]]='adult'
sc.pl.umap(adata, color='donortype')
```

Example 89 (unknown):
```unknown
... storing 'cmtype' as categorical
```

Example 90 (unknown):
```unknown
... storing 'donortype' as categorical
```

Example 91 (python):
```python
bdata=adata[adata.obs.cmtype=='ventricular',:].copy()
ClusterOfInterest='fetal'
sc.tl.rank_genes_groups(bdata, 'donortype', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:150]]
DEGenesForCluster=list(set(DEGenesForCluster)-set(mito_genes)-set(ribo_genes))
FetalVentricularList=DEGenesForCluster
sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='donortype',standard_scale='var',cmap='PRGn')
#sc.pl.umap(bdata, color=DEGenesForCluster)

ClusterOfInterest='adult'
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:150]]
DEGenesForCluster=list(set(DEGenesForCluster)-set(mito_genes)-set(ribo_genes))
AdultVentricularList=DEGenesForCluster
sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='donortype',standard_scale='var',cmap='PRGn')

bdata=adata[adata.obs.cmtype=='atrial',:].copy()
ClusterOfInterest='fetal'
sc.tl.rank_genes_groups(bdata, 'donortype', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:150]]
DEGenesForCluster=list(set(DEGenesForCluster)-set(mito_genes)-set(ribo_genes))
FetalAtrialList=DEGenesForCluster
sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='donortype',standard_scale='var',cmap='PRGn')
#sc.pl.umap(bdata, color=DEGenesForCluster)

ClusterOfInterest='adult'
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:150]]
DEGenesForCluster=list(set(DEGenesForCluster)-set(mito_genes)-set(ribo_genes))
AdultAtrialList=DEGenesForCluster
sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='donortype',standard_scale='var',cmap='PRGn')
```

Example 92 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:04)
```

Example 93 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
```

Example 94 (python):
```python
CommonAdult=list(set(AdultVentricularList)&set(AdultAtrialList))
CommonFetal=list(set(FetalVentricularList)&set(FetalAtrialList))

sc.pl.dotplot(adata, CommonAdult ,groupby='donortype',standard_scale='var',cmap='PRGn')
sc.pl.dotplot(adata, CommonFetal ,groupby='donortype',standard_scale='var',cmap='PRGn')
```

Example 95 (python):
```python
bdata=adata[adata.obs.cmtype=='ventricular',:].copy()
ClusterOfInterest='fetal'
sc.tl.rank_genes_groups(bdata, 'donortype', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:500]]
#DEGenesForCluster=list(set(DEGenesForCluster)-set(mito_genes)-set(ribo_genes))
FetalVentricularList=DEGenesForCluster
#sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='donortype',standard_scale='var',cmap='PRGn')
#sc.pl.umap(bdata, color=DEGenesForCluster)

ClusterOfInterest='adult'
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:500]]
#DEGenesForCluster=list(set(DEGenesForCluster)-set(mito_genes)-set(ribo_genes))
AdultVentricularList=DEGenesForCluster
#sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='donortype',standard_scale='var',cmap='PRGn')

bdata=adata[adata.obs.cmtype=='atrial',:].copy()
ClusterOfInterest='fetal'
sc.tl.rank_genes_groups(bdata, 'donortype', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:500]]
#DEGenesForCluster=list(set(DEGenesForCluster)-set(mito_genes)-set(ribo_genes))
FetalAtrialList=DEGenesForCluster
#sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='donortype',standard_scale='var',cmap='PRGn')
#sc.pl.umap(bdata, color=DEGenesForCluster)

ClusterOfInterest='adult'
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:500]]
#DEGenesForCluster=list(set(DEGenesForCluster)-set(mito_genes)-set(ribo_genes))
AdultAtrialList=DEGenesForCluster
#sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='donortype',standard_scale='var',cmap='PRGn')

CommonAdult=list(set(AdultVentricularList)&set(AdultAtrialList))
CommonFetal=list(set(FetalVentricularList)&set(FetalAtrialList))

CommonAdultTFs=list(set(CommonAdult)&set(TFs))
CommonFetalTFs=list(set(CommonFetal)&set(TFs))

sc.pl.dotplot(adata, CommonAdultTFs ,groupby='donortype',standard_scale='var',cmap='PRGn')
sc.pl.dotplot(adata, CommonFetalTFs ,groupby='donortype',standard_scale='var',cmap='PRGn')
```

Example 96 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:05)
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
```

Example 97 (python):
```python
sc.pl.dotplot(adata, 'SOX4' ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
```

Example 98 (python):
```python
adata = adata[adata.obs['mid_grain'].isin(['AtrialCardiomyocytes','VentricularCardiomyocytes','CardiacConductionSystem'])].copy()
```

Example 99 (unknown):
```unknown
AnnData object with n_obs × n_vars = 74884 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 100 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 101 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:13)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1821
```

Example 102 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'CDCA7', 'PRIM1', 'UHRF1', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    369 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'ANP32E', 'RANGAP1', 'LBR', 'CTCF', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    768 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 103 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 104 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [05:18<00:00,  6.37s/it, loss=800, v_num=1]
```

Example 105 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'SOCS3', 'CEBPD', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    596 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBB', 'HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    248 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:07)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:21)
```

Example 106 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 107 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 108 (python):
```python
sc.pl.umap(adata, color='fine_grain')
```

Example 109 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesLeftCompact'])].copy()
```

Example 110 (python):
```python
adata.obs['compactortrabeculated']= 'na'
adata.obs['compactortrabeculated'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightTrabeculated']]]='trabeculated'
adata.obs['compactortrabeculated'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['VentricularCardiomyocytesLeftCompact','VentricularCardiomyocytesRightCompact']]]='compact'
sc.pl.umap(adata, color='compactortrabeculated')
```

Example 111 (unknown):
```unknown
... storing 'compactortrabeculated' as categorical
```

Example 112 (python):
```python
ClusterOfInterest='trabeculated'
sc.tl.rank_genes_groups(adata, 'compactortrabeculated', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='compactortrabeculated',standard_scale='var',cmap='YlGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 113 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
```

Example 114 (python):
```python
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][50:100]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',cmap='YlGn')
```

Example 115 (python):
```python
sc.pl.dotplot(adata, ['SEMA5A','ADCY5','CORIN','SIPA1L1','ADAMTSL1','CRNDE','SGCD','MYOM2','VCAN','SPOCK1','PPP2R2B','ANGPT1'], categories_order=['VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesLeftCompact','VentricularCardiomyocytesRightCompact'],groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 116 (python):
```python
set(adata.obs.fine_grain)
```

Example 117 (unknown):
```unknown
{'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated'}
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_ventricularCM.html

**Contents:**
- Variables¶
- Read in data¶
- Markers¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

15516 rows × 8 columns

--> cluster 1 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-09 21:18
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'VentricularCardiomyocytes'
```

Example 10 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 188122 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([2.4982107, 2.4982107, 2.4982107, 2.4982107, 3.5404415],
      dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 3min 38s, sys: 1.89 s, total: 3min 39s
Wall time: 3min 40s
```

Example 21 (python):
```python
# read in markers identified using single-nucleus data
markers_df = pd.read_csv(f'/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_{celltype}_finegrain_markers.csv')

mask1 = markers_df['group_mean']>0.1
mask2 = markers_df['logfoldchanges']>0.1
markers_df = markers_df[mask1&mask2]

markers_df
```

Example 22 (python):
```python
markers = {}
n_top = 10
for c in set(markers_df['group']):
    markers_df_sub = markers_df[markers_df['group']==c]
    markers_df_sub.sort_values('logfoldchanges',ascending=False)
    markers[c]=list(markers_df_sub[:n_top]['names'])

# manually add genes
markers['VentricularConductionSystemProximal'] = markers['VentricularConductionSystemProximal']+['TBX3','PRDM16','NIBAN1','PHACTR1','FGF18'] # 'PRDM16','NIBAN1','PHACTR1','FGF18' are the markers compared to VCSdistal
markers['VentricularConductionSystemDistal'] = markers['VentricularConductionSystemDistal']+['SEMA3A','IRX2','IRX3','OPCML','NTN1','EPHA4','GABRB2'] 
markers['Cycling'] = ['MKI67'] 

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in list(adata.var_names))&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in list(adata.var_names)]
len(genes)
```

Example 23 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",color=genes, size=10,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 24 (unknown):
```unknown
resolution_sel = 1
```

Example 25 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              markers_others, 
              groupby=f'leiden_{str(resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 26 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 27 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 28 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: VentricularConductionSystemProximal, VentricularCardiomyocytesCycling, VentricularConductionSystemDistal, etc.
```

Example 29 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 30 (unknown):
```unknown
[2.4982107 2.4982107 2.4982107 2.4982107 3.5404415]
```

Example 31 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 32 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 33 (unknown):
```unknown
'VentricularCardiomyocytes'
```

Example 34 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'VentricularCardiomyocytes',
    '1':'unassigned',
    '2':'VentricularCardiomyocytes',
    '3':'VentricularCardiomyocytes',
    '4':'VentricularCardiomyocytes',
    '5':'VentricularCardiomyocytesCycling',
    '6':'VentricularCardiomyocytes',
    '7':'VentricularCardiomyocytes',
    '8':'VentricularCardiomyocytes',
    '9':'VentricularCardiomyocytes',
    '10':'VentricularCardiomyocytes',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 35 (python):
```python
/tmp/ipykernel_66828/1515001482.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 36 (unknown):
```unknown
tmp_annotation
VentricularCardiomyocytes           135389
unassigned                           39920
VentricularCardiomyocytesCycling     12813
Name: count, dtype: int64
```

Example 37 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 38 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['VentricularCardiomyocytes'])]
```

Example 39 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 40 (unknown):
```unknown
AnnData object with n_obs × n_vars = 135389 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 41 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 42 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 135389 × 4535
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 43 (python):
```python
'''
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
'''
```

Example 44 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 45 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
```

Example 46 (unknown):
```unknown
number of hvgs: 631
```

Example 47 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-06-09 21:27:35,158 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-09 21:27:47,956 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-09 21:27:48,553 - harmonypy - INFO - Iteration 1 of 10
2025-06-09 21:28:34,773 - harmonypy - INFO - Iteration 2 of 10
2025-06-09 21:29:29,154 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 48 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 49 (unknown):
```unknown
CPU times: user 5min 22s, sys: 2.48 s, total: 5min 24s
Wall time: 5min 25s
```

Example 50 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",size=10,
                color=genes,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 51 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=["conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 52 (python):
```python
# umap per celltype to highlight
group_col = 'celltypist_midmod2fine'
groups_to_plot = list(set(adata_sub.obs[group_col]))

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,8))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                    color=[group_col], groups=grp, 
               size=10, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 53 (unknown):
```unknown
sub_resolution_sel = 2
```

Example 54 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              markers_others, 
              groupby=f'leiden_{str(sub_resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 55 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 56 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 57 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: VentricularConductionSystemProximal, VentricularCardiomyocytesCycling, VentricularConductionSystemDistal, etc.
```

Example 58 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 59 (unknown):
```unknown
[2.4982107 2.4982107 2.4982107 2.4982107 3.5404415]
```

Example 60 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
```

Example 61 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 62 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'VentricularCardiomyocytes',
    '1':'VentricularCardiomyocytes',
    '2':'VentricularCardiomyocytes',
    '3':'VentricularCardiomyocytesCycling',
    '4':'VentricularCardiomyocytes',
    '5':'VentricularConductionSystemDistal',
    '6':'VentricularCardiomyocytes',
    '7':'VentricularCardiomyocytes',
    '8':'VentricularCardiomyocytes',
    '9':'VentricularCardiomyocytes',
    '10':'VentricularCardiomyocytes',
    '11':'VentricularCardiomyocytes',
    '12':'VentricularCardiomyocytes',
    '13':'VentricularCardiomyocytesCycling',
    '14':'?SkeletalMuscle',
    '15':'VentricularCardiomyocytesCycling',
    '16':'?ThyroidCells',
    '17':'VentricularCardiomyocytes',
    '18':'VentricularCardiomyocytes',
    '19':'VentricularCardiomyocytes',
    '20':'VentricularCardiomyocytes',
    '21':'VentricularCardiomyocytes',
    '22':'VentricularCardiomyocytes',
    '23':'VentricularCardiomyocytes',
    '24':'VentricularCardiomyocytes',
    '25':'VentricularCardiomyocytes',
    '26':'VentricularCardiomyocytes',
    '27':'VentricularCardiomyocytes',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 63 (python):
```python
/tmp/ipykernel_66828/1113603435.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 64 (unknown):
```unknown
fine_grain_manual
VentricularCardiomyocytes            104353
VentricularCardiomyocytesCycling      17703
VentricularConductionSystemDistal      9595
?SkeletalMuscle                        2891
?ThyroidCells                           847
Name: count, dtype: int64
```

Example 65 (unknown):
```unknown
'VentricularCardiomyocytes'
```

Example 66 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 67 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 68 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 69 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
                  spot_size=60,vmax='p100')
```

Example 70 (python):
```python
/tmp/ipykernel_66828/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 71 (python):
```python
/tmp/ipykernel_66828/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 72 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=30,vmax='p100')
```

Example 73 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 74 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 75 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 76 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 77 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 78 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 79 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 80 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 81 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 82 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 83 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 84 (python):
```python
/tmp/ipykernel_66828/3828796421.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 85 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 86 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_VentricularCardiomyocytes_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Leukocytes/No3_Myeloid_post-scVI.html

**Contents:**
- Import modules¶
- Function¶
- Read in data¶
- Log-normalise¶
- Clustering, UMAP¶
  - Deciding resolution¶
- Marker gene expressions¶
- DEG analysis¶
- CellTypist prediction¶
- Annotation¶
- Recover row counts and save¶
- Celltypist, pan-foetal immune¶
- CellTypist prediction: EL-YS¶
- Check matching with previoius annotation¶

**Examples:**

Example 1 (python):
```python
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import matplotlib.pyplot as plt
import anndata


import celltypist
from celltypist import models

import sctk
import os
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
-----
anndata             0.8.0
celltypist          0.1.9
matplotlib          3.5.2
numpy               1.21.5
pandas              1.3.5
scanpy              1.8.2
sctk                NA
session_info        1.0.0
-----
```

Example 4 (python):
```python
PIL                 9.1.1
asciitree           NA
backcall            0.2.0
beta_ufunc          NA
binom_ufunc         NA
brotli              NA
cached_property     1.5.1
cairo               1.20.0
certifi             2020.12.05
cffi                1.14.4
chardet             3.0.4
charset_normalizer  2.0.10
cloudpickle         1.6.0
colorama            0.4.4
cycler              0.10.0
cython_runtime      NA
cytoolz             0.11.2
dask                2022.01.0
dateutil            2.8.1
decorator           4.4.2
defusedxml          0.6.0
fasteners           0.17.3
fsspec              2022.01.0
google              NA
h5py                3.1.0
idna                2.10
igraph              0.10.2
importlib_metadata  1.7.0
ipykernel           5.4.2
ipython_genutils    0.2.0
ipywidgets          7.6.3
jedi                0.17.2
jinja2              3.1.2
joblib              1.0.0
kiwisolver          1.3.1
leidenalg           0.9.0
llvmlite            0.35.0
louvain             0.7.0
markupsafe          2.1.1
mpl_toolkits        NA
msgpack             1.0.3
natsort             7.1.0
nbinom_ufunc        NA
numba               0.52.0
numcodecs           0.9.1
numexpr             2.7.2
numpy_groupies      0.9.13
packaging           21.3
parso               0.7.1
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
plotly              5.10.0
prompt_toolkit      3.0.10
psutil              5.9.0
ptyprocess          0.7.0
pyarrow             9.0.0
pygments            2.13.0
pyparsing           2.4.7
pytz                2020.5
requests            2.27.1
scipy               1.7.3
scvelo              0.2.4
seaborn             0.11.1
setuptools_scm      NA
sinfo               0.3.1
six                 1.14.0
sklearn             1.0.2
socks               1.7.1
sphinxcontrib       NA
statsmodels         0.12.1
storemagic          NA
tables              3.6.1
tblib               1.7.0
texttable           1.6.3
threadpoolctl       2.1.0
tlz                 0.11.2
toolz               0.11.2
tornado             6.1
traitlets           5.0.5
typing_extensions   NA
urllib3             1.26.9
wcwidth             0.2.5
yaml                5.4.1
zarr                2.11.3
zipp                NA
zmq                 21.0.1
zope                NA
```

Example 5 (unknown):
```unknown
-----
IPython             7.19.0
jupyter_client      6.1.11
jupyter_core        4.7.0
notebook            6.2.0
-----
Python 3.7.9 | packaged by conda-forge | (default, Dec  9 2020, 21:08:20) [GCC 9.3.0]
Linux-4.15.0-112-generic-x86_64-with-debian-bullseye-sid
-----
Session information updated at 2023-03-09 09:25
```

Example 6 (python):
```python
sc.settings.set_figure_params(dpi=120, facecolor='white', color_map = 'RdPu',)
```

Example 7 (python):
```python
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# extract rank_genes_groups result 
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

import scanpy as sc
import pandas as pd

def rank_genes_groups_to_df(adata, cell):
    
    dic = adata.uns['rank_genes_groups'] 
    
    df = pd.DataFrame({
        'names' : dic['names'][cell],
        'scores' : dic['scores'][cell],
        'pvals' : dic['pvals'][cell],
        'pvals_adj' : dic['pvals_adj'][cell],
        'logfoldchanges' : dic['logfoldchanges'][cell]
    })
    
    return df
```

Example 8 (unknown):
```unknown
compartment = 'Myeloid'
```

Example 9 (python):
```python
adata = sc.read_h5ad(f'/home/jovyan/mount/gdrive/Colab/data/scVI/subsets/RNA_foetal_{compartment}_post-scVI_16Feb2023.h5ad')
adata
```

Example 10 (unknown):
```unknown
AnnData object with n_obs × n_vars = 18527 × 28267
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2'
    var: 'gene_name_scRNA-0', 'gene_id', 'n_cells'
    uns: '_scvi_manager_uuid', '_scvi_uuid'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 11 (python):
```python
# normalise and logtransform
# adata.raw = adata
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
```

Example 12 (python):
```python
%%time

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata, min_dist=0.2, spread=1.0, n_components=3)

resolutions = [0.2,0.3,0.4,0.5,0.6,] # 0.7,0.8,0.9,1.0
for res in resolutions:
    print(res)
    sc.tl.leiden(adata, resolution=res, key_added=f'leiden_scVI_{res}')
    sc.pl.umap(adata, color=[f'leiden_scVI_{res}'], size=5, components='all', wspace=0.5)
```

Example 13 (python):
```python
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata, min_dist=0.2, spread=1.0, n_components=3)
sc.tl.leiden(adata, resolution=1, key_added='leiden_scVI')
```

Example 14 (python):
```python
sc.pl.umap(adata, color=['leiden_scVI'], size=5, wspace=0.1, legend_loc='on data', legend_fontsize=10,components='all')
```

Example 15 (python):
```python
sc.pl.umap(adata, color=['region','donor','cell_or_nuclei','kit_10x'], size=5, wspace=0.7)
```

Example 16 (python):
```python
sc.pl.umap(adata, color=['region'],groups='Pericardium', size=5, wspace=0.7,components='all')
```

Example 17 (python):
```python
sc.pl.umap(adata, color=['scrublet_score','cluster_scrublet_score','doublet_pval','doublet_bh_pval','pct_counts_mt','pct_counts_ribo'], size=2, wspace=0.2, ncols=6)
```

Example 18 (python):
```python
genes=['CCR2','CLEC10A','LYVE1','FOLR2','CX3CR1','TIMD4','MERTK','TREM2','COL1A1','HLA-DPA1']
genes = [x for x in genes if x in adata.var_names]
sc.pl.umap(adata, color=genes, size=20, wspace=0.2, ncols=6, components='all')
```

Example 19 (python):
```python
# Checking glabal markers
markers = {
    'vCM': ['MYH7', 'MYL2', 'FHL2'],
    'aCM': ['NPPA', 'MYL7', 'MYL4'],
    'FB': ['DCN', 'GCN', 'PDGFRA'],
    'EC': ['VWF', 'PECAM1', 'CDH5'],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby='leiden_scVI')
sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 20 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: vCM, aCM, FB, etc.
```

Example 21 (python):
```python
# lymphocytes markers

markers={
    'B cell': ['CD19', 'CD79A', 'CD79B', 'IGHM', 'IGHG1', 'IGHA1'],
    'T cell': ['CD3E', 'CD3D', 'TRAC', 'CD4', 'CD8A', 'CD8B'],
    'naive': ['CCR7', 'TCF7', 'LEF1', 'SELL'],
    'act': ['IL2','CD69'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2'],
    'cytotoxic': ['PRF1', 'GZMB', 'GZMH', 'NKG7'],
    'trans': ['GZMK', 'TOX'],
    'te': ['TIGIT', 'LAG3', 'PDCD1'],
    'em': ['IL7R', 'RUNX2'],
    'MAIT': ['SLC4A10', 'KLRB1', 'CCR6'],
    'NK': ['KLRF1', 'KLRD1', 'NCAM1', 'FCGR3A'],
    'ILC': ['KIT', 'IL18R1'],
    'cycling': ['MKI67', 'TOP2A', 'UBE2C'],
    'TFs': ['TBX21', 'GATA3', 'RORC', 'BCL6',],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 22 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: B cell, T cell, naive, etc.
```

Example 23 (python):
```python
markers={
    'Mono':['CCR2','CD14','FCGR3A','CX3CR1','FCGR1A','FCN1','TREM2'],
    'MP':['C1QA','C1QB','CD68','LYVE1','IGF1','FOLR2','DOCK4','MRC1','P2RY12','SALL1','C3','OLFML3','HTRA1'],
    'PS-R':['TIMD4','MERTK','AXL','SIRPA','CD300A','ITGAV','ITGB3','ITGB5'],
    'M2MP':['CD163','MRC1','CLEC10A'],
    'DC':['FLT3','FCER1A','CD1C','HLA-DPA1','HLA-DPB1','CCR7'],
    'DC1':['ID2','IRF8','BATF3','CLEC9A'],
    'DC2':['CLEC10A','CD1C','FCER1A',],
    'Neutro':['MYB', 'MPO', 'CEACAM8','CXCR1','CXCR2'],
    'collagen':['COL1A1','COL1A2','COL3A1','NLRP3'],
    'FOS-JUN':['FOS','JUN'],
    'Cycling':['MKI67','TOP2A'],

}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 24 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: Mono, MP, PS-R, etc.
```

Example 25 (python):
```python
adata.X.data[:10]
```

Example 26 (python):
```python
sc.tl.rank_genes_groups(adata, 'leiden_scVI', method='t-test')

DEG_dict = {}
for cluster in adata.obs['leiden_scVI'].cat.categories:
    df=rank_genes_groups_to_df(adata, cluster)
    # select genes: significant and up-regulated ones
    df=df[(df['pvals_adj']<0.05)&(df['logfoldchanges']>0)]
    # sort based on the logFC
    df.sort_values('scores',ascending=False,inplace=True)
    DEG_dict[cluster]=list(df[:10]['names'])
    del df

sc.pl.dotplot(adata,
              DEG_dict, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 27 (python):
```python
# load model and predict
panfetal_model = models.Model.load('/nfs/team205/kk18/Analysis/celltypist/models/celltypist_model.Pan_Fetal_Human.pkl')
prediction=celltypist.annotate(adata, model = panfetal_model, majority_voting = True)
```

Example 28 (unknown):
```unknown
🔬 Input data has 18527 cells and 28267 genes
🔗 Matching reference genes in the model
🧬 6636 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
👀 Detected a neighborhood graph in the input object, will run over-clustering on the basis of it
⛓️ Over-clustering input data with resolution set to 10
🗳️ Majority voting the predictions
✅ Majority voting done!
```

Example 29 (unknown):
```unknown
celltypist.dotplot(prediction, use_as_reference = 'leiden_scVI', use_as_prediction = 'predicted_labels')
```

Example 30 (python):
```python
sc.pl.umap(adata, color=['leiden_scVI'], size=5, wspace=0.1, legend_loc='on data', components='all', legend_fontsize=10)
```

Example 31 (python):
```python
set(adata.obs['2Jan_fine_grain'])
```

Example 32 (unknown):
```unknown
{'B1Cells',
 'BCells',
 'Cardiofibromyocytes',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronaryVesselAdventitialFibroblasts',
 'DC1',
 'DC2',
 'DCsMature',
 'DCsPlasmocytoids',
 'EarlyGreatVesselFLRT2',
 'EndocardialCells',
 'GVAdFibOCA2',
 'GVAdFibOther',
 'InnateLymphoidCells',
 'LymphaticEndothelialCells',
 'MacrophagesCX3CR1pos',
 'MacrophagesInflammasome',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MacrophagesTREM2pos',
 'MastCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocIntFibROBO2',
 'MyocIntFibSLIT3',
 'Myofibroblasts',
 'NaturalKillerCells',
 'SchwannCells',
 'TCellsCD8pos',
 'Tregs',
 'ValvePENK',
 nan}
```

Example 33 (python):
```python
sc.pl.umap(adata, color=['2Jan_fine_grain'], groups='MacrophagesTREM2pos' ,size=5, wspace=0.1, legend_loc='on data', components='all', legend_fontsize=10)
```

Example 34 (python):
```python
sc.pl.umap(adata, color=['TIMD4','LYVE1','FOLR2','CX3CR1','TREM2','FOS','MKI67','ATF3','TLR4'], size=10, wspace=0.1, 
           legend_loc='on data', components='all', legend_fontsize=10,ncols=3)
```

Example 35 (python):
```python
pd.crosstab(adata.obs['leiden_scVI'],adata.obs['region'])
```

Example 36 (python):
```python
adata.obs['cell_type3']=adata.obs['leiden_scVI'].astype('str').copy()
adata.obs.replace({'cell_type3':{
    '0':'MP_CX3CR1+', 
    '1':'MP_LYVE1+', 
    '2':'MP_LYVE1+', 
    '3':'MP_LYVE1+', 
    '4':'MP_LYVE1+_cycling', 
    '5':'MP_LYVE1+ATF3+', 
    '6':'MP_LYVE1+', 
    '7':'MP_LYVE1+',   
    '8':'MP_LYVE1+',  
    '9':'MP_LYVE1+', 
    '10':'Mono', 
    '11':'MP_LYVE1+', 
    '12':'MP_LYVE1+', 
    '13':'MP_LYVE1+ATF3+', 
    '14':'MP_LYVE1+', 
    '15':'Mono-derived', 
    '16':'DC1', 
    '17':'Doublet',   
    '18':'MP_LYVE1+_cycling', 
    '19':'MP_TIMD4+',
    '20':'Mono_MPO+', 
}}, inplace=True)


adata.obs['cell_type3']=adata.obs['cell_type3'].astype('category')
adata.obs['cell_type3'].cat.reorder_categories([
    'Mono', 
    'Mono_MPO+', 
    'Mono-derived', 
    'MP_CX3CR1+',
    # 'MP_TREM2+', 
    'MP_TIMD4+', 
    'MP_LYVE1+',
    # 'MP_LYVE1+MHCIIhi', 
    'MP_LYVE1+ATF3+',
    'MP_LYVE1+_cycling',
    'DC1',
    'Doublet',  
], inplace=True)

adata.obs['cell_type3'].value_counts()
```

Example 37 (javascript):
```javascript
MP_LYVE1+            9748
MP_LYVE1+ATF3+       1844
MP_LYVE1+_cycling    1650
MP_CX3CR1+           1648
Mono                  900
Mono-derived          661
DC1                   609
Doublet               583
MP_TIMD4+             470
Mono_MPO+             414
Name: cell_type3, dtype: int64
```

Example 38 (python):
```python
markers={
  'Mono':['CCR2','CD14','FCGR3A','CX3CR1','FCGR1A','FCN1','TREM2'],
    'MP':['C1QA','C1QB','CD68','LYVE1','IGF1','FOLR2','DOCK4'],
    'PS-R':['TIMD4','MERTK','AXL','SIRPA','CD300A','ITGAV','ITGB3','ITGB5'],
    'M2MP':['CD163','MRC1','CLEC10A'],
    'DC':['FLT3','FCER1A','CD1C','HLA-DPA1','HLA-DPB1','CCR7'],
    'DC1':['ID2','IRF8','BATF3','CLEC9A'],
    'DC2':['CLEC10A','CD1C','FCER1A',],
    'Neutro':['MYB', 'MPO', 'CEACAM8','CXCR1','CXCR2'],
    'collagen':['COL1A1','COL1A2','COL3A1'],
    'FOS-JUN':['FOS','JUN'],
    'Inflammasome':['NLRP1','NLRP3','PYCARD','CASP1'],
    'Cycling':['MKI67','TOP2A'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 39 (python):
```python
markers={
    'Mono':['CCR2','FCN1','MPO'],
    'Mono-derived':['CLEC10A','CD1C'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163','LYVE1','FOLR2'],
    'CX3CR1+':['CX3CR1','FCGR1A','FCGR3A','C3','P2RY12','SALL1','C3','OLFML3','HTRA1','TREM2',],
    'PtdSer-R':['TIMD4','MERTK','AXL','ITGAV'],
    'ATF3':['ATF3'],
    'ATF3':['ATF3'],
    'DC general':['FLT3','HLA-DPA1','HLA-DPB1','CIITA'],
    'DC1':['ID2','BATF3','CLEC9A'],
    'Cycling':['MKI67','TOP2A'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata[adata.obs['cell_type3']!='Doublet'],
              markers, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 40 (python):
```python
sc.settings.set_figure_params(dpi=120,  color_map = 'RdPu',)
sc.pl.umap(adata, color=['cell_type3'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 41 (python):
```python
sc.tl.rank_genes_groups(adata, 'cell_type3', method='t-test')

DEG_dict = {}
for cluster in adata.obs['cell_type3'].cat.categories:
    df=rank_genes_groups_to_df(adata, cluster)
    # select genes: significant and up-regulated ones
    df=df[(df['pvals_adj']<0.05)&(df['logfoldchanges']>0)]
    # sort based on the logFC
    df.sort_values('scores',ascending=False,inplace=True)
    DEG_dict[cluster]=list(df[:10]['names'])
    del df

sc.pl.dotplot(adata,
              DEG_dict, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 42 (python):
```python
adata_raw=sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_immune_16Feb2023.h5ad')
print(adata_raw.shape)

adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp # from annotated or subsetted data
                               )
print(adata_raw.shape)
```

Example 43 (unknown):
```unknown
(41881, 36601)
(18527, 36601)
```

Example 44 (python):
```python
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Myeloid_16Feb2023.h5ad')
adata_raw
```

Example 45 (unknown):
```unknown
AnnData object with n_obs × n_vars = 18527 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2', 'cell_type3'
    var: 'gene_name_scRNA-0', 'gene_id'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 46 (python):
```python
sc.pl.umap(adata_raw, color=['cell_type3'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 47 (python):
```python
adata_raw = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Myeloid_16Feb2023.h5ad')
adata_raw
```

Example 48 (unknown):
```unknown
AnnData object with n_obs × n_vars = 18527 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2', 'cell_type3'
    var: 'gene_name_scRNA-0', 'gene_id'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 49 (python):
```python
# save metadata
adata_raw.obs.to_csv('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_Myeloid_16Feb2023.obs.csv')
```

Example 50 (python):
```python
adata = adata_raw.copy()
# normalise and logtransform
# adata.raw = adata
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
```

Example 51 (python):
```python
markers={
    'Mono':['CCR2','FCN1','MPO'],
    # 'Mono-derived':['CLEC10A','CD1C'],
    'MP':['C1QA','C1QB','CD68','MRC1','CD163'],
    'CX3CR1+':['CX3CR1','C3','TREM2','OLFMl3','P2RY12'],
    'PtdSer-R':['TIMD4','MERTK','ITGAV'],
    'LYVE1+':['LYVE1','FOLR2'],
    'ATF3':['ATF3'],
    'Cycling':['MKI67'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata[adata.obs['cell_type3'].isin(['Doublet','DC1'])==False],
              markers, 
              groupby='cell_type3',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 52 (python):
```python
sc.pl.umap(adata, 
           color=['AREG','CCL24'], size=10, wspace=0.1, 
           legend_loc='on data', components='all', legend_fontsize=10,ncols=3)
```

Example 53 (python):
```python
sc.pl.umap(adata, 
           color=['GATA6'], size=10, wspace=0.1, 
           legend_loc='on data', components='all', legend_fontsize=10,ncols=3)
```

Example 54 (python):
```python
sc.pl.umap(adata, 
           color=['region'], groups='Pericardium', size=10, wspace=0.1, 
           legend_loc='on data', components='all', legend_fontsize=10,ncols=3)
```

Example 55 (python):
```python
sc.pl.umap(adata[adata.obs['cell_type3']=='Mono-derived'], 
           color=['CCR2','CLEC10A','CD1C'], size=10, wspace=0.1, 
           legend_loc='on data', components='all', legend_fontsize=10,ncols=3)
```

Example 56 (python):
```python
# load model and predict
panfetal_model = models.Model.load('/nfs/team205/kk18/Analysis/celltypist/models/celltypist_model.Pan_Fetal_Human.pkl')
prediction=celltypist.annotate(adata, model = panfetal_model, majority_voting = False)
celltypist.dotplot(prediction, use_as_reference = 'cell_type3', use_as_prediction = 'predicted_labels')
```

Example 57 (unknown):
```unknown
🔬 Input data has 18527 cells and 28267 genes
🔗 Matching reference genes in the model
🧬 6636 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
```

Example 58 (python):
```python
# load model
elys_model = models.Model.load('/nfs/team205/heart/anndata_objects/Haniffa_YolkSac/celltypist_EL-YS_myeloid.pkl')
prediction=celltypist.annotate(adata, model = elys_model, majority_voting = False)
celltypist.dotplot(prediction, use_as_reference = 'cell_type3', use_as_prediction = 'predicted_labels')
```

Example 59 (unknown):
```unknown
🔬 Input data has 18527 cells and 28267 genes
🔗 Matching reference genes in the model
🧬 16762 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
```

Example 60 (python):
```python
adata = prediction.to_adata(insert_labels = True, insert_conf = True)
```

Example 61 (python):
```python
sc.pl.umap(adata, color=['predicted_labels'], size=5, legend_fontsize=10, frameon=False, wspace=1,components=['1,2','1,3'])
```

Example 62 (python):
```python
sc.pl.umap(adata, color=['conf_score'], size=5, legend_fontsize=10, frameon=False, wspace=0.5, components='all')
```

Example 63 (python):
```python
pd.crosstab(adata.obs['cell_type3'],adata.obs['2Jan_fine_grain']).T
```

Example 64 (python):
```python
import seaborn as sns
plt.rcParams['figure.figsize'] = 12,5
df=pd.crosstab(adata.obs['cell_type3'],adata.obs['2Jan_fine_grain'],normalize='columns')
sns.heatmap(df)
```

Example 65 (unknown):
```unknown
<AxesSubplot:xlabel='2Jan_fine_grain', ylabel='cell_type3'>
```

Example 66 (python):
```python
import seaborn as sns
plt.rcParams['figure.figsize'] = 13,5
ad=adata[adata.obs['2Jan_fine_grain']!='nan']
df=pd.crosstab(ad.obs['cell_type3'],ad.obs['2Jan_fine_grain'],normalize='index')
sns.heatmap(df)
```

Example 67 (unknown):
```unknown
<AxesSubplot:xlabel='2Jan_fine_grain', ylabel='cell_type3'>
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Annotations/ImmuneAnnotationKazumasa.html

**Examples:**

Example 1 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 2 (unknown):
```unknown
Global seed set to 0
```

Example 3 (unknown):
```unknown
Running Scanpy 1.8.1, on 2022-12-21 19:40.
```

Example 4 (python):
```python
adata=sc.read('./Objects/Annotated/Mesenchymal.h5ad')
print(adata.shape)

#sc.pp.normalize_total(adata, target_sum=1e4)
#sc.pp.log1p(adata)
```

Example 5 (unknown):
```unknown
(129898, 2479)
```

Example 6 (python):
```python
set(adata.obs.new_fine_grain)
```

Example 7 (unknown):
```unknown
{'B',
 'B1',
 'B_cycling',
 'Bpro',
 'CD4+T',
 'CD4+Treg',
 'CD8+T',
 'DC1',
 'DC2',
 'DC_mature',
 'Doublet',
 'ILC',
 'MP_CX3CR1+',
 'MP_LYVE1+',
 'MP_LYVE1+Collagen+',
 'MP_LYVE1+JUN+',
 'MP_LYVE1+_cycling',
 'MP_TIMD4+',
 'MP_TREM2+',
 'Mast cell',
 'Mono',
 'Mono_MPO+',
 'NK',
 'Plasmacytoid DC',
 'T-NK_cycling'}
```

Example 8 (python):
```python
#ClustersToStay=['T-NK_cycling','NK','CD8+T','CD4+Treg','CD4+T']
#adata=adata[[x for x in adata.obs_names if adata.obs.new_fine_grain[x] in ClustersToStay],:].copy()
#sc.pl.umap(adata, color='new_fine_grain')


adata=adata[adata.obs.new_fine_grain=='T-NK_cycling',:].copy()
#adata
```

Example 9 (python):
```python
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.3)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 10 (python):
```python
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:00)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:01)
```

Example 11 (python):
```python
#sc.pl.umap(adata, color='new_fine_grain')
#sc.pl.umap(adata, color=['CD8Anew_fine_grain')
sc.pl.umap(adata, color=['NKG7','TGFBR3','GZMA'])
sc.pl.umap(adata, color=['CSGALNACT1','ANK3'])
sc.pl.umap(adata, color=['NELL2'])
sc.pl.umap(adata, color=['BCL2','RTKN2','GBP2'])
```

Example 12 (python):
```python
bdata=adata[adata.obs.new_fine_grain=='T-NK_cycling',:].copy()
sc.pl.umap(bdata, color=['CD7','NCAM1','FOXP3'])
```

Example 13 (python):
```python
sc.tl.leiden(adata, resolution=0.4, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 14 (python):
```python
running Leiden clustering
    finished: found 8 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 15 (python):
```python
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 16 (python):
```python
ClustersToStay=['5']

bdata=adata[[x for x in adata.obs_names if adata.obs.leiden[x] in ClustersToStay],:].copy()

bdatanames=bdata.obs_names

print(len(bdatanames))
np.savetxt('BAdd.txt', bdatanames, delimiter="\n", fmt="%s")
```

Example 17 (unknown):
```unknown
AnnData object with n_obs × n_vars = 2138 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'age_binned', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.4', 'leiden_scVI_0.5', 'leiden_scVI_0.6', 'cell_type2', 'new_fine_grain', 'new_mid_grain'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'cell_type2_colors', 'fine_grain_colors', 'mid_grain_colors', 'new_fine_grain_colors', 'new_mid_grain_colors', 'log1p', 'neighbors', 'umap', 'phase_colors', 'donor_colors', 'sex_colors', 'age_colors', 'region_colors', 'cell_or_nuclei_colors', 'modality_colors', 'kit_10x_colors', 'FACSgate_colors', 'leiden', 'leiden_colors', 'rank_genes_groups', 'dendrogram_leiden'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 18 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 19 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
    using 'X_pca' with n_pcs = 50
Storing dendrogram info using `.uns['dendrogram_leiden']`
```

Example 20 (python):
```python
cdata=sc.read('./Objects/Annotated/Immune.h5ad')
sc.pl.dotplot(cdata, ['CD74','VPREB3','CD74','CD79B'] ,groupby='new_fine_grain',standard_scale='var',cmap='PRGn')
```

Example 21 (python):
```python
ClusterOfInterest='CD4+Treg'
#sc.tl.rank_genes_groups(adata, 'new_fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='new_fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 22 (python):
```python
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
Genes=['PTPRC']
sc.pl.umap(adata, color=Genes)
```

Example 23 (python):
```python
sc.pl.umap(adata, color=['new_fine_grain'],groups=['B','B1','B_cycling','Bpro'])
sc.pl.umap(adata, color=['new_fine_grain'],groups=['CD4+T','
sc.pl.umap(adata, color=['new_fine_grain'],groups=['ILC'])
sc.pl.umap(adata, color=['new_fine_grain'],groups=['MP_CX3CR1+','MP_LYVE1+','MP_LYVE1+Collagen+','MP_LYVE1+JUN+','MP_LYVE1+_cycling','MP_TIMD4+','MP_TREM2+'])
sc.pl.umap(adata, color=['new_fine_grain'],groups=['Mono','Mono_MPO+'])
sc.pl.umap(adata, color=['new_fine_grain'],groups=['Mast cell'])
sc.pl.umap(adata, color=['new_fine_grain'],groups=['DC1','DC2','DC_mature','Plasmacytoid DC'])CD4+Treg','CD8+T','T-NK_cycling','NK'])
```

Example 24 (python):
```python
sc.pl.umap(adata, color=['new_fine_grain'],groups=['DC2','Plasmacytoid DC'])
```

Example 25 (python):
```python
sc.pl.umap(adata, color=['phase'])
```

Example 26 (python):
```python
sc.pl.umap(adata, color=['new_fine_grain'],groups=['MP_CX3CR1+','MP_LYVE1+','MP_LYVE1+Collagen+','MP_LYVE1+JUN+','MP_LYVE1+_cycling','MP_TIMD4+','MP_TREM2+'])
sc.pl.umap(adata, color=['new_fine_grain'],groups=['MP_LYVE1+Collagen+'])
```

Example 27 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='new_fine_grain', method='t-test')
sc.tl.dendrogram(adata, groupby='new_fine_grain')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='new_fine_grain', standard_scale='var')
```

Example 28 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:08)
    using 'X_pca' with n_pcs = 50
Storing dendrogram info using `.uns['dendrogram_new_fine_grain']`
```

Example 29 (python):
```python
sc.pl.dotplot(adata, ['MS4A1','PCDH9','ERG','RORC','CCL5','CD8A','FOXP3','ANK3','GATA2','CUX2','LAMP3','CLEC10A','CLNK','LYVE1','STX11','NLRP3','NR4A3','TIMD4','TREM2','CX3CR1','MPO','PLBD1'] ,groupby='new_fine_grain',standard_scale='var',cmap='PRGn')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Annotations/EpicardiumAnnotation.html

**Examples:**

Example 1 (unknown):
```unknown
#Epicardial annotation
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2022-12-20 11:13.
```

Example 5 (python):
```python
adata=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(306287, 36601)
```

Example 7 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 8 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 9 (python):
```python
set(adata.obs.coarse_grain)
```

Example 10 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Immune',
 'Mesenchymal',
 'Neural'}
```

Example 11 (python):
```python
adata=adata[adata.obs.coarse_grain=='Epicardium',:].copy()
adata
```

Example 12 (unknown):
```unknown
AnnData object with n_obs × n_vars = 3879 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 13 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata
```

Example 14 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:06)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1166
```

Example 15 (python):
```python
# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()
```

Example 16 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'PCNA', 'FEN1', 'MCM2', 'MCM4', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    164 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['CKS1B', 'TMPO', 'CKAP2L', 'ANP32E', 'HJURP', 'CDC25C', 'KIF2C', 'RANGAP1', 'CDCA2', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    519 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 17 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 18 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:15<00:00,  3.21it/s, loss=930, v_num=1]
```

Example 19 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 20 (python):
```python
# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.3)
#sc.tl.tsne(adata)
```

Example 21 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    221 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBB', 'HBD', 'HBE1', 'HBZ', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    143 total control genes are used. (0:00:00)
computing score 'hb2_score'
WARNING: genes are not in var_names and ignored: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS']
    finished: added
    'hb2_score', score of gene set (adata.obs).
    48 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:02)
```

Example 22 (python):
```python
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','hb2_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)
```

Example 23 (python):
```python
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 24 (python):
```python
sc.pl.umap(adata, color='previous_fine_grain')
```

Example 25 (python):
```python
sc.pl.umap(adata, color=['TCF21','POSTN','TBX18'])
```

Example 26 (python):
```python
sc.tl.leiden(adata, resolution=0.05, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 27 (python):
```python
running Leiden clustering
    finished: found 2 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 28 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 29 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
    using 'X_pca' with n_pcs = 50
Storing dendrogram info using `.uns['dendrogram_leiden']`
```

Example 30 (unknown):
```unknown
WARNING: Dendrogram not added. Dendrogram is added only when the number of categories to plot > 2
```

Example 31 (python):
```python
set(adata.obs.previous_fine_grain)
```

Example 32 (unknown):
```unknown
{'Cardiofibromyocytes',
 'CoronaryEndothelialCellsArterial',
 'CoronaryVesselAdventitialFibroblasts',
 'EarlyGreatVesselCells',
 'EndocardialCells',
 'FibroblasticEpicardialCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselSmoothMuscleCells',
 'MesothelialEpicardialCells',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'ValveInterstitialCells',
 nan}
```

Example 33 (python):
```python
adata.obs['fine_grain']= 'na'

adata.obs['fine_grain'][adata.obs['leiden']=='0']='MesothelialEpicardialCells'
adata.obs['fine_grain'][adata.obs['leiden']=='1']='FibroblasticEpicardialCells'

sc.pl.umap(adata, color='fine_grain')
```

Example 34 (unknown):
```unknown
... storing 'fine_grain' as categorical
```

Example 35 (python):
```python
adata.write('./Objects/Annotated/Epicardium.h5ad')
##adata=sc.read('./Objects/Annotated/Epicardium.h5ad')
```

Example 36 (python):
```python
adata=sc.read('./Objects/Annotated/Epicardium.h5ad')
```

Example 37 (python):
```python
set(adata.obs.fine_grain)
```

Example 38 (unknown):
```unknown
{'FibroblasticEpicardialCells', 'MesothelialEpicardialCells'}
```

Example 39 (python):
```python
bdata=adata[adata.obs.fine_grain=='MesothelialEpicardialCells',:].copy()
bdatanames=bdata.obs_names

np.savetxt('MesothelialEpicardialCells.txt', bdatanames, delimiter="\n", fmt="%s")
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_neurons.html

**Contents:**
- Variables¶
- Read in data¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 2 and 6 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-12 17:35
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'Neurons'
```

Example 10 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 1992 × 4270
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([3.4320538, 3.4320538, 4.1089087, 3.4320538, 3.4320538],
      dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 1.46 s, sys: 62.3 ms, total: 1.52 s
Wall time: 1.52 s
```

Example 21 (python):
```python
# markers for fine-grained cell types
markers = {
    "ChromaffinCells": [
        'DLK1',
        'EPAS1',
        'KCNJ6',
        "TH",    # Tyrosine hydroxylase
        "PNMT",  # Phenylethanolamine N-methyltransferase
        "CHGA",  # Chromogranin A
        "CHGB",  # Chromogranin B
        "PHOX2B"
    ],
    "NeuronPrecursors": [
        "NES",    # Nestin
        "PAX6",   # Paired box 6
        "TUBB3",  # Tubulin Beta 3 Class III
        "DCX",     # Doublecortin
        'ASCL1','NELL2','BNC2'
    ],
    "ParasympatheticNeurons": [
        "PHOX2B",
        "CHAT",    # Choline O-Acetyltransferase
        "SLC18A3", # Solute Carrier Family 18 Member A3 (Vesicular Acetylcholine Transporter)
        "GATA3",
        'NEFL','SST'
    ],
    "SympatheticNeurons": [
        "TH",
        "PHOX2B",
        "GATA3",
        "CHGA",
        "CHGB",
        'DBH','VSTM2L'
    ],
    'Cycling':['MKI67','TOP2A']
}
genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]
    
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 22 (unknown):
```unknown
resolution_sel = 1.5
```

Example 23 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 24 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: ChromaffinCells, NeuronPrecursors, ParasympatheticNeurons, etc.
```

Example 25 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 26 (unknown):
```unknown
[3.4320538 3.4320538 4.1089087 3.4320538 3.4320538]
```

Example 27 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 28 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 29 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'Neurons',
    '1':'Neurons',
    '2':'unassigned',
    '3':'Neurons',
    '4':'Neurons',
    '5':'Neurons',
    '6':'unassigned',
    '7':'Neurons',
    '8':'Neurons',
    '9':'Neurons',
    '10':'Neurons',
    '11':'Neurons',
    '12':'Neurons',
    '13':'Neurons',
    '14':'Neurons',
    '15':'Neurons',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 30 (python):
```python
/tmp/ipykernel_350881/479757587.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 31 (unknown):
```unknown
tmp_annotation
Neurons       1597
unassigned     395
Name: count, dtype: int64
```

Example 32 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 33 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['Neurons'])]
```

Example 34 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 35 (unknown):
```unknown
AnnData object with n_obs × n_vars = 1597 × 4270
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1.5', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 36 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 37 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 1597 × 3822
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_1.5', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 38 (python):
```python
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
```

Example 39 (unknown):
```unknown
(1597, 3769)
```

Example 40 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 41 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 42 (unknown):
```unknown
number of hvgs: 818
```

Example 43 (python):
```python
2025-06-12 17:39:31,715 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-12 17:39:31,970 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-12 17:39:32,016 - harmonypy - INFO - Iteration 1 of 10
2025-06-12 17:39:32,138 - harmonypy - INFO - Iteration 2 of 10
2025-06-12 17:39:32,245 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 44 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 45 (unknown):
```unknown
CPU times: user 2.66 s, sys: 106 ms, total: 2.77 s
Wall time: 2.78 s
```

Example 46 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 47 (unknown):
```unknown
sub_resolution_sel = 1
```

Example 48 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 49 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: ChromaffinCells, NeuronPrecursors, ParasympatheticNeurons, etc.
```

Example 50 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 51 (unknown):
```unknown
[3.4320538 3.4320538 4.1089087 3.4320538 3.4320538]
```

Example 52 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 53 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=['celltypist_midmod2fine', 'conf_score_midmod2fine'],
                wspace=0.7)
```

Example 54 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'ParasympatheticNeurons',
    '1':'NeuronPrecursors',
    '2':'SympatheticNeurons',
    '3':'NeuronPrecursors',
    '4':'ParasympatheticNeurons',
    '5':'ParasympatheticNeurons',
    '6':'ChromaffinCells',
    '7':'EntericLikeNeurons'
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 55 (python):
```python
/tmp/ipykernel_350881/3142940995.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 56 (unknown):
```unknown
fine_grain_manual
ParasympatheticNeurons    657
NeuronPrecursors          513
SympatheticNeurons        276
ChromaffinCells           106
EntericLikeNeurons         45
Name: count, dtype: int64
```

Example 57 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=['NOS1', 'VIP', 'CARTPT', 'RET','TBX3'],
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 58 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 59 (python):
```python
# markers for fine-grained cell types
markers = {
    "ChromaffinCells": [
        'DLK1',
        'EPAS1',
        'KCNJ6',
        "TH",    # Tyrosine hydroxylase
        "PNMT",  # Phenylethanolamine N-methyltransferase
        "CHGA",  # Chromogranin A
        "CHGB",  # Chromogranin B
        "PHOX2B"
    ],
    "NeuronPrecursors": [
        "NES",    # Nestin
        "PAX6",   # Paired box 6
        "TUBB3",  # Tubulin Beta 3 Class III
        "DCX",     # Doublecortin
        'ASCL1','NELL2','BNC2'
    ],
    "ParasympatheticNeurons": [
        "PHOX2B",
        "CHAT",    # Choline O-Acetyltransferase
        "SLC18A3", # Solute Carrier Family 18 Member A3 (Vesicular Acetylcholine Transporter)
        "GATA3",
        'NEFL','SST'
    ],
    "SympatheticNeurons": [
        "TH",
        "PHOX2B",
        "GATA3",
        "CHGA",
        "CHGB",
        'DBH','VSTM2L'
    ],
    'EntericNeurons':['NOS1', 'VIP', 'CARTPT', 'RET'],
    'Cycling':['MKI67','TOP2A']
}
genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata_sub,groupby='fine_grain_manual')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 60 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: ParasympatheticNeurons, NeuronPrecursors, SympatheticNeurons, etc.
var_group_labels: ChromaffinCells, NeuronPrecursors, ParasympatheticNeurons, etc.
```

Example 61 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 62 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 63 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
                  spot_size=60,vmax='p100')
```

Example 64 (python):
```python
/tmp/ipykernel_350881/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 65 (python):
```python
/tmp/ipykernel_350881/4023824168.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
```

Example 66 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],groups='ParasympatheticNeurons',
                  spot_size=80,vmax='p100')
```

Example 67 (python):
```python
/tmp/ipykernel_350881/2352066969.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='ParasympatheticNeurons',
```

Example 68 (python):
```python
/tmp/ipykernel_350881/2352066969.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='ParasympatheticNeurons',
```

Example 69 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],groups='SympatheticNeurons',
                  spot_size=60,vmax='p100')
```

Example 70 (python):
```python
/tmp/ipykernel_350881/1588966400.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='SympatheticNeurons',
```

Example 71 (python):
```python
/tmp/ipykernel_350881/1588966400.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='SympatheticNeurons',
```

Example 72 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],groups='EntericLikeNeurons',
                  spot_size=80,vmax='p100')
```

Example 73 (python):
```python
/tmp/ipykernel_350881/1078245424.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='EntericLikeNeurons',
```

Example 74 (python):
```python
/tmp/ipykernel_350881/1078245424.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='EntericLikeNeurons',
```

Example 75 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 76 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_Neurons_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Annotations/EndotheliumAnnotation.html

**Examples:**

Example 1 (unknown):
```unknown
#Endothelium Annotation
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2022-12-20 11:15.
```

Example 5 (python):
```python
adata=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(306287, 36601)
```

Example 7 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 8 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 9 (python):
```python
set(adata.obs.coarse_grain)
```

Example 10 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Immune',
 'Mesenchymal',
 'Neural'}
```

Example 11 (python):
```python
adata=adata[adata.obs.coarse_grain=='Endothelium',:].copy()
adata
```

Example 12 (unknown):
```unknown
AnnData object with n_obs × n_vars = 21882 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 13 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata
```

Example 14 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:09)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
2625
```

Example 15 (python):
```python
# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()
```

Example 16 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['FEN1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    498 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'ANP32E', 'CDC25C', 'CDCA2', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    779 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 17 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 18 (unknown):
```unknown
Epoch 50/50: 100%|███████| 50/50 [01:54<00:00,  2.29s/it, loss=1.2e+03, v_num=1]
```

Example 19 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 20 (python):
```python
# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
```

Example 21 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    342 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    299 total control genes are used. (0:00:00)
computing score 'hb2_score'
WARNING: genes are not in var_names and ignored: ['GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS']
    finished: added
    'hb2_score', score of gene set (adata.obs).
    50 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:03)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:06)
```

Example 22 (python):
```python
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','hb2_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)
```

Example 23 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 24 (python):
```python
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 25 (python):
```python
sc.pl.umap(adata, color='previous_fine_grain')
```

Example 26 (python):
```python
#this block is to see where the cells over a certain threshold with TNNT2 expression lies in the UMAP
#enter what gene to set threshold for
#when running this box for the first time, comment the starting with 'del'
#then uncomment it for the other ones --- !!!

CellName='Cardio_toremove'
gene='TTN'
exp_thresh=3
gene_pos=adata.var_names.get_loc(gene)
adata_sel = adata[adata.X[:,gene_pos]>exp_thresh].copy()

l=adata_sel.obs_names
set(l).intersection(adata.obs_names)
print(len(l))

#del adata.obs[CellName]
adata.obs.loc[set(l).intersection(adata.obs_names),CellName]='Yes'
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=[CellName], groups='Yes',size=10, wspace=0.45, legend_fontsize=5, legend_loc='on data',frameon=False)

print(adata)
adata= adata[adata.X[:,gene_pos]<exp_thresh].copy()
print(adata)
```

Example 27 (unknown):
```unknown
... storing 'Cardio_toremove' as categorical
```

Example 28 (unknown):
```unknown
AnnData object with n_obs × n_vars = 21882 × 2625
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
AnnData object with n_obs × n_vars = 21273 × 2625
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 29 (python):
```python
#this block is to see where the cells over a certain threshold with TNNT2 expression lies in the UMAP
#enter what gene to set threshold for
#when running this box for the first time, comment the starting with 'del'
#then uncomment it for the other ones --- !!!

CellName='Mesenchymal_toremove'
gene='COL6A3'
exp_thresh=1.5
gene_pos=adata.var_names.get_loc(gene)
adata_sel = adata[adata.X[:,gene_pos]>exp_thresh].copy()

l=adata_sel.obs_names
set(l).intersection(adata.obs_names)
print(len(l))

#del adata.obs[CellName]
adata.obs.loc[set(l).intersection(adata.obs_names),CellName]='Yes'
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=[CellName], groups='Yes',size=10, wspace=0.45, legend_fontsize=5, legend_loc='on data',frameon=False)

print(adata)
adata= adata[adata.X[:,gene_pos]<exp_thresh].copy()
print(adata)
```

Example 30 (unknown):
```unknown
... storing 'Mesenchymal_toremove' as categorical
```

Example 31 (unknown):
```unknown
AnnData object with n_obs × n_vars = 21273 × 2625
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove', 'Mesenchymal_toremove'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors', 'Mesenchymal_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
AnnData object with n_obs × n_vars = 20129 × 2625
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove', 'Mesenchymal_toremove'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors', 'Mesenchymal_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 32 (python):
```python
#Re-run analyis with cardio-mesenchymal removed

adata_raw=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')

print(adata_raw)
# constructing new anndata with maintaining .obs, .obsm, .obsp, .uns
# overwriting adata_raw
adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp, # from annotated or subsetted data
                    uns=adata.uns # from annotated or subsetted data
                               )

adata=adata_raw.copy()
print(adata)
```

Example 33 (unknown):
```unknown
AnnData object with n_obs × n_vars = 306287 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
AnnData object with n_obs × n_vars = 20129 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove', 'Mesenchymal_toremove'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors', 'Mesenchymal_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 34 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','hb2_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 35 (python):
```python
normalizing counts per cell
    finished (0:00:00)
WARNING: adata.X seems to be already log-transformed.
extracting highly variable genes
    finished (0:00:09)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
2493
```

Example 36 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['FEN1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    497 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'ANP32E', 'CDC25C', 'CDCA2', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    779 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 37 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 38 (unknown):
```unknown
Epoch 50/50: 100%|██████| 50/50 [01:47<00:00,  2.14s/it, loss=1.13e+03, v_num=1]
```

Example 39 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    345 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    344 total control genes are used. (0:00:00)
computing score 'hb2_score'
WARNING: genes are not in var_names and ignored: ['GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS']
    finished: added
    'hb2_score', score of gene set (adata.obs).
    50 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:05)
```

Example 40 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 41 (unknown):
```unknown
<Figure size 800x800 with 0 Axes>
```

Example 42 (python):
```python
sc.pl.umap(adata, color='previous_fine_grain')
```

Example 43 (python):
```python
sc.pl.umap(adata, color='region')
```

Example 44 (python):
```python
TipGenes=['ADM',' ANKRD37',' C1QTNF6',' CLDN5',' COL4A1',' COL4A2',' COTL1',' DLL4',' EDNRB',' FSCN1',' GPIHBP1',' HSPG2',' IGFBP3',' INHBB',' JUP',' KCNE3',' KCNJ8',' LAMA4',' LAMB1',' LXN',' MARCKSL1',' MCAM',' MEST',' N4BP3',' NID2',' NOTCH4',' PLOD1',' PLXND1',' PMEPA1',' PTN',' RAMP3',' RBP1',' RGCC',' RHOC',' TRP53ILL',' UNC5B',' PRND',' LYH6']
sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.tl.score_genes(adata, TipGenes, score_name='TipScore')
sc.pl.umap(adata, color='TipScore')
```

Example 45 (python):
```python
computing score 'TipScore'
WARNING: genes are not in var_names and ignored: [' ANKRD37', ' C1QTNF6', ' CLDN5', ' COL4A1', ' COL4A2', ' COTL1', ' DLL4', ' EDNRB', ' FSCN1', ' GPIHBP1', ' HSPG2', ' IGFBP3', ' INHBB', ' JUP', ' KCNE3', ' KCNJ8', ' LAMA4', ' LAMB1', ' LXN', ' MARCKSL1', ' MCAM', ' MEST', ' N4BP3', ' NID2', ' NOTCH4', ' PLOD1', ' PLXND1', ' PMEPA1', ' PTN', ' RAMP3', ' RBP1', ' RGCC', ' RHOC', ' TRP53ILL', ' UNC5B', ' PRND', ' LYH6']
    finished: added
    'TipScore', score of gene set (adata.obs).
    49 total control genes are used. (0:00:00)
```

Example 46 (python):
```python
sc.tl.leiden(adata, resolution=0.25, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 47 (python):
```python
running Leiden clustering
    finished: found 9 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 48 (python):
```python
#adata.write('./Objects/Cardiomyocytes.h5ad')
##adata=sc.read('./Objects/Cardiomyocytes.h5ad')
```

Example 49 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 50 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:02)
    using 'X_pca' with n_pcs = 50
Storing dendrogram info using `.uns['dendrogram_leiden']`
```

Example 51 (python):
```python
#Dive into great and coronary vessel endothelial cells
adata=adata.copy()
ClustersToStay=['2','5','0','8','7']
adata=adata[[x for x in adata.obs_names if adata.obs.leiden[x] in ClustersToStay],:].copy()
adata

adata_raw=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')

print(adata_raw)
# constructing new anndata with maintaining .obs, .obsm, .obsp, .uns
# overwriting adata_raw
adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp, # from annotated or subsetted data
                    uns=adata.uns # from annotated or subsetted data
                               )

adata=adata_raw.copy()
print(adata)

# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
#sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 52 (python):
```python
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:02)
```

Example 53 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 54 (python):
```python
sc.pl.umap(adata, color=['region'])
```

Example 55 (python):
```python
TipGenes=['ADM',' ANKRD37',' C1QTNF6',' CLDN5',' COL4A1',' COL4A2',' COTL1',' DLL4',' EDNRB',' FSCN1',' GPIHBP1',' HSPG2',' IGFBP3',' INHBB',' JUP',' KCNE3',' KCNJ8',' LAMA4',' LAMB1',' LXN',' MARCKSL1',' MCAM',' MEST',' N4BP3',' NID2',' NOTCH4',' PLOD1',' PLXND1',' PMEPA1',' PTN',' RAMP3',' RBP1',' RGCC',' RHOC',' TRP53ILL',' UNC5B',' PRND',' LYH6']
sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.tl.score_genes(adata, TipGenes, score_name='TipScore')
sc.pl.umap(adata, color='TipScore')
```

Example 56 (python):
```python
computing score 'TipScore'
WARNING: genes are not in var_names and ignored: [' ANKRD37', ' C1QTNF6', ' CLDN5', ' COL4A1', ' COL4A2', ' COTL1', ' DLL4', ' EDNRB', ' FSCN1', ' GPIHBP1', ' HSPG2', ' IGFBP3', ' INHBB', ' JUP', ' KCNE3', ' KCNJ8', ' LAMA4', ' LAMB1', ' LXN', ' MARCKSL1', ' MCAM', ' MEST', ' N4BP3', ' NID2', ' NOTCH4', ' PLOD1', ' PLXND1', ' PMEPA1', ' PTN', ' RAMP3', ' RBP1', ' RGCC', ' RHOC', ' TRP53ILL', ' UNC5B', ' PRND', ' LYH6']
    finished: added
    'TipScore', score of gene set (adata.obs).
    49 total control genes are used. (0:00:00)
```

Example 57 (python):
```python
sc.tl.leiden(adata, resolution=0.45, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 58 (python):
```python
running Leiden clustering
    finished: found 10 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 59 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
    using 'X_pca' with n_pcs = 50
Storing dendrogram info using `.uns['dendrogram_leiden']`
```

Example 60 (python):
```python
adata.obs['fine_grain']= '100'

GreatVesselVenousEndothelialCells=['9']
GreatVesselArterialEndothelialCells=['0','6']
CoronaryCapillaryEndothelialCells=['8','2','5','1','4']
CoronaryVenousEndothelialCells=['7']
CoronaryArterialEndothelialCells=['3']

adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in GreatVesselVenousEndothelialCells]]='GreatVesselVenousEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in GreatVesselArterialEndothelialCells]]='GreatVesselArterialEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in CoronaryCapillaryEndothelialCells]]='CoronaryCapillaryEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in CoronaryVenousEndothelialCells]]='CoronaryVenousEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in CoronaryArterialEndothelialCells]]='CoronaryArterialEndothelialCells'

sc.pl.umap(adata, color='fine_grain')
```

Example 61 (unknown):
```unknown
... storing 'fine_grain' as categorical
```

Example 62 (python):
```python
#adata.write('./Objects/Annotated/EndotheliumCoronaryAndGreatVessels.h5ad')
##adata=sc.read('./Objects/Cardiomyocytes.h5ad')
```

Example 63 (python):
```python
adata.obs['fine_grain']= '100'

LymphaticEndothelialCells=['3']
EndocardialCells=['1']
ValveEndothelialCells=['6']
EndocardialCushionCells=['4']

adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in LymphaticEndothelialCells]]='LymphaticEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in EndocardialCells]]='EndocardialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in ValveEndothelialCells]]='ValveEndothelialCells'
adata.obs['fine_grain'][[x for x in adata.obs_names if adata.obs.leiden[x] in EndocardialCushionCells]]='EndocardialCushionCells'

sc.pl.umap(adata, color='fine_grain')
```

Example 64 (unknown):
```unknown
... storing 'fine_grain' as categorical
```

Example 65 (python):
```python
bdata=sc.read('./Objects/Annotated/EndotheliumCoronaryAndGreatVessels.h5ad')
set(bdata.obs.fine_grain)
```

Example 66 (unknown):
```unknown
{'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryVenousEndothelialCells',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselVenousEndothelialCells'}
```

Example 67 (python):
```python
set(adata.obs.fine_grain)
```

Example 68 (unknown):
```unknown
{'100',
 'EndocardialCells',
 'EndocardialCushionCells',
 'LymphaticEndothelialCells',
 'ValveEndothelialCells'}
```

Example 69 (python):
```python
adata.obs['fine_grain']= '0'

for k in range(1, len(adata)+1):
    if adata.obs_names[k-1] in CoronaryArterialEndothelialCells:
        adata.obs.fine_grain[k-1]='CoronaryArterialEndothelialCells'   
    if adata.obs_names[k-1] in CoronaryCapillaryEndothelialCells:
        adata.obs.fine_grain[k-1]='CoronaryCapillaryEndothelialCells' 
    if adata.obs_names[k-1] in CoronaryVenousEndothelialCells:
        adata.obs.fine_grain[k-1]='CoronaryVenousEndothelialCells' 
    if adata.obs_names[k-1] in GreatVesselArterialEndothelialCells:
        adata.obs.fine_grain[k-1]='GreatVesselArterialEndothelialCells' 
    if adata.obs_names[k-1] in GreatVesselVenousEndothelialCells:
        adata.obs.fine_grain[k-1]='GreatVesselVenousEndothelialCells'   
    if adata.obs_names[k-1] in EndocardialCells:
        adata.obs.fine_grain[k-1]='EndocardialCells' 
    if adata.obs_names[k-1] in EndocardialCushionCells:
        adata.obs.fine_grain[k-1]='EndocardialCushionCells' 
    if adata.obs_names[k-1] in LymphaticEndothelialCells:
        adata.obs.fine_grain[k-1]='LymphaticEndothelialCells' 
    if adata.obs_names[k-1] in ValveEndothelialCells:
        adata.obs.fine_grain[k-1]='ValveEndothelialCells'         

sc.pl.umap(adata, color='fine_grain')
```

Example 70 (unknown):
```unknown
... storing 'fine_grain' as categorical
```

Example 71 (python):
```python
adata.write('./Objects/Annotated/Endothelium.h5ad')
##adata=sc.read('./Objects/Cardiomyocytes.h5ad')
```

Example 72 (python):
```python
adata=sc.read('./Objects/Annotated/Endothelium.h5ad')
```

Example 73 (python):
```python
set(adata.obs.fine_grain)
```

Example 74 (unknown):
```unknown
{'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryVenousEndothelialCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselVenousEndothelialCells',
 'LymphaticEndothelialCells',
 'ValveEndothelialCells'}
```

Example 75 (python):
```python
sc.pl.umap(adata, color='BMP4')
```

Example 76 (python):
```python
bdata=adata[adata.obs.fine_grain=='ValveEndothelialCells',:].copy()
bdatanames=bdata.obs_names

np.savetxt('ValveEndothelialCells.txt', bdatanames, delimiter="\n", fmt="%s")
bdata
```

Example 77 (unknown):
```unknown
AnnData object with n_obs × n_vars = 1042 × 2493
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove', 'Mesenchymal_toremove', 'TipScore', 'fine_grain'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'Cardio_toremove_colors', 'FACSgate_colors', 'Mesenchymal_toremove_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'fine_grain_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'previous_fine_grain_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no04_mark_multi_celltypes_coarse.html

**Contents:**
- Read in adata¶
- Plot leiden clusters¶
- Mark ?suspicious clusters in the center¶
- Save¶

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import celltypist
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
-----
celltypist          1.6.3
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 4 (python):
```python
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
certifi             2025.01.31
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
idna                3.10
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
requests            2.32.3
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
urllib3             2.3.0
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 5 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.45.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-05-30 00:11
```

Example 6 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 7 (python):
```python
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
adata
```

Example 8 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_mid_fin_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 9 (unknown):
```unknown
os.getcwd()
```

Example 10 (unknown):
```unknown
'/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/Xenium/5K/C194_Hst45/CamU'
```

Example 11 (python):
```python
adata.X.data[:5]
```

Example 12 (unknown):
```unknown
array([5., 1., 1., 2., 2.], dtype=float32)
```

Example 13 (unknown):
```unknown
latent_space = 'pca_harmony'
leiden_keys=[]
for res in [0.2,0.3,0.4,0.5,0.8,1.0,1.5,2.0,3.0]:
    leiden_key = f"leiden_{res}"
    key_added=f"{latent_space}_{leiden_key}"
    leiden_keys.append(key_added)
```

Example 14 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=leiden_keys,
                   ncols=4
                   )
```

Example 15 (python):
```python
# plot celltypist prediction, for reference
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color=['celltypist_coarse2midmod','conf_score_coarse2midmod'],
                   ncols=4,wspace=0.7
                   )
```

Example 16 (python):
```python
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color=['celltypist_coarse','conf_score_coarse'],
                   ncols=4,wspace=0.5
                   )
```

Example 17 (unknown):
```unknown
leiden_key_sel = 'pca_harmony_leiden_1.0'
```

Example 18 (python):
```python
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color=leiden_key_sel,
                   ncols=4
                   )
```

Example 19 (python):
```python
markers = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=leiden_key_sel)
sc.pl.dotplot(adata,
              markers, 
              groupby=leiden_key_sel,
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 20 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 21 (python):
```python
# mark potentially multiple cell type cells
clusters_to_mark = ['5','10']
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color=leiden_key_sel,
                groups=clusters_to_mark,
                   ncols=4
                   )
```

Example 22 (python):
```python
adata.obs['multi_celltypes_coarse'] = 'No'
obsnames = adata.obs_names[adata.obs[leiden_key_sel].isin(clusters_to_mark)]
adata.obs.loc[obsnames,'multi_celltypes_coarse']='Yes'
sc.pl.embedding(adata,
                    basis=f"X_umap_{latent_space}",
                    color='multi_celltypes_coarse',
                
                   )
```

Example 23 (unknown):
```unknown
... storing 'multi_celltypes_coarse' as categorical
```

Example 24 (python):
```python
adata.obs_names
```

Example 25 (unknown):
```unknown
Index(['C194-HEA-0-FFPE-1_aaaafiob-1', 'C194-HEA-0-FFPE-1_aaaajopp-1',
       'C194-HEA-0-FFPE-1_aaaanald-1', 'C194-HEA-0-FFPE-1_aaabdjka-1',
       'C194-HEA-0-FFPE-1_aaabglmg-1', 'C194-HEA-0-FFPE-1_aaachofo-1',
       'C194-HEA-0-FFPE-1_aaadibmf-1', 'C194-HEA-0-FFPE-1_aaaenklb-1',
       'C194-HEA-0-FFPE-1_aaafclmo-1', 'C194-HEA-0-FFPE-1_aaafjldl-1',
       ...
       'Hst45-HEA-0-FFPE-1_oigbdbao-1', 'Hst45-HEA-0-FFPE-1_oigbenna-1',
       'Hst45-HEA-0-FFPE-1_oigbmoed-1', 'Hst45-HEA-0-FFPE-1_oigcbndd-1',
       'Hst45-HEA-0-FFPE-1_oigcinom-1', 'Hst45-HEA-0-FFPE-1_oigcomgh-1',
       'Hst45-HEA-0-FFPE-1_oigeappc-1', 'Hst45-HEA-0-FFPE-1_oigeiifh-1',
       'Hst45-HEA-0-FFPE-1_oigeklem-1', 'Hst45-HEA-0-FFPE-1_oigenchi-1'],
      dtype='object', length=362277)
```

Example 26 (python):
```python
adata.write(path_adata)
path_adata
```

Example 27 (unknown):
```unknown
'/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_neurons-glia.html

**Contents:**
- Variables¶
- Read in data¶

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
# import session_info
# session_info.show()
```

Example 3 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 4 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 5 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
# celltype = 'Neurons'
```

Example 6 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 7 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 8 (python):
```python
# read in
ad1 = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_Neurons_lognorm.h5ad')
ad2 = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_Glia_lognorm.h5ad')

adata = ad1.concatenate(ad2, 
            join='inner', 
            batch_key=None, 
            index_unique=None)
adata
```

Example 9 (python):
```python
/tmp/ipykernel_349665/1641403099.py:5: FutureWarning: Use anndata.concat instead of AnnData.concatenate, AnnData.concatenate is deprecated and will be removed in the future. See the tutorial for concat at: https://anndata.readthedocs.io/en/latest/concatenation.html
  adata = ad1.concatenate(ad2,
```

Example 10 (unknown):
```unknown
AnnData object with n_obs × n_vars = 8968 × 4226
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'tmp_annotation', 'fine_grain_manual'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells-0', 'highly_variable-0', 'means-0', 'dispersions-0', 'dispersions_norm-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells-1', 'highly_variable-1', 'means-1', 'dispersions-1', 'dispersions_norm-1'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
```

Example 11 (python):
```python
adata.X.data[:5]
```

Example 12 (unknown):
```unknown
array([3.4320538, 3.4320538, 3.4320538, 3.4320538, 3.4320538],
      dtype=float32)
```

Example 13 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group'].isin(['Neurons','Glia'])==False]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata.var_names]
bdata = adata[:,mask]
bdata
```

Example 14 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 8968 × 3793
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'tmp_annotation', 'fine_grain_manual'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells-0', 'highly_variable-0', 'means-0', 'dispersions-0', 'dispersions_norm-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells-1', 'highly_variable-1', 'means-1', 'dispersions-1', 'dispersions_norm-1'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
```

Example 15 (python):
```python
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
```

Example 16 (unknown):
```unknown
(8968, 3740)
```

Example 17 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata,min_dist=0.1,neighbors_key=latent_space)
adata.obsm[f"X_umap_{latent_space}"]=adata.obsm["X_umap"]
del adata.obsm["X_umap"]
```

Example 18 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 19 (unknown):
```unknown
number of hvgs: 827
```

Example 20 (python):
```python
2025-06-12 17:52:22,562 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-12 17:52:25,016 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-12 17:52:25,108 - harmonypy - INFO - Iteration 1 of 10
2025-06-12 17:52:26,304 - harmonypy - INFO - Iteration 2 of 10
2025-06-12 17:52:27,502 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 21 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 22 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['fine_grain_manual'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 23 (python):
```python
group_col = 'fine_grain_manual'
groups_to_plot = adata.obs[group_col].unique()
basis = f"X_umap_{latent_space}"

ncols = 6
if len(groups_to_plot)%ncols==0:
    nrows = len(groups_to_plot)//ncols
else:
    nrows = len(groups_to_plot)//ncols+1

if len(groups_to_plot)<ncols:
    fig_width = len(groups_to_plot)%ncols
else:
    fig_width = ncols
    
fig,axs=plt.subplots(nrows=nrows,ncols=ncols,figsize=(fig_width*5,nrows*5))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    # ad = adata.copy()
    # update colors
    # get color in adata
    # ind = list(ad.obs[group_col].cat.categories).index(celltype)
    # ad.uns[group_col][ind] = 'darkred'
    
    # title
    middle_ind = round(len(grp)/2)
    # grp_title = f'{grp[:middle_ind]}\n{grp[middle_ind:]}'
    # plot
    sc.pl.embedding(adata, basis=basis,
                  color=group_col, groups=grp,
                  size=20,legend_loc=None,
                  frameon=False,title=grp,
                  show=False, ax=axs_flat[i],
                 )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 24 (python):
```python
# markers for fine-grained cell types
markers = {
    'Neuronal':['NEFL','RBFOX3'],
    "ChromaffinCells": [
        'DLK1',
        'EPAS1',
        'KCNJ6',
        "TH",    # Tyrosine hydroxylase
        "PNMT",  # Phenylethanolamine N-methyltransferase
        "CHGA",  # Chromogranin A
        "CHGB",  # Chromogranin B
        "PHOX2B"
    ],
    "NeuronPrecursors": [
        "NES",    # Nestin
        "PAX6",   # Paired box 6
        "TUBB3",  # Tubulin Beta 3 Class III
        "DCX",     # Doublecortin
        'ASCL1','NELL2','BNC2'
    ],
    "ParasympatheticNeurons": [
        "PHOX2B",
        "CHAT",    # Choline O-Acetyltransferase
        "SLC18A3", # Solute Carrier Family 18 Member A3 (Vesicular Acetylcholine Transporter)
        "GATA3",
        'NEFL','SST'
    ],
    "SympatheticNeurons": [
        "TH",
        "PHOX2B",
        "GATA3",
        "CHGA",
        "CHGB",
        'DBH','VSTM2L'
    ],
    'EntericNeurons':['NOS1', 'VIP', 'CARTPT', 'RET'],
    
     "astrocytes": ["GFAP", "S100B", "ALDH1L1"],
    "oligodendrocytes": ["OLIG2", "MBP", "PDGFRA"],
    "microglia": ["AIF1"],  # IBA1 protein is encoded by the AIF1 gene
    "schwann_cells": ["SOX10", "MPZ", "S100B"],
    "schwann_cell_precursors": [
                                "PLS3",'SLITRK6','IL1RAPL2'
                               ],
    "ependymal cells":[
                    "FOXJ1",  # Forkhead box J1
                    "S100B",  # S100 Calcium Binding Protein B
                    "VIM",    # Vimentin
                    "PROM1",  # Prominin-1 (CD133)
                    "CDH1",   # Cadherin 1 (E-cadherin)
                    "EPCAM"   # Epithelial Cell Adhesion Molecule
    ],
    
    'Cycling':['MKI67','TOP2A']
}
genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in adata.var_names)&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata,groupby='fine_grain_manual')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 25 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: ?EpendymalCells, ChromaffinCells, EntericLikeNeurons, etc.
var_group_labels: Neuronal, ChromaffinCells, NeuronPrecursors, etc.
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Supplementary_materials/Epigenetic_stability/no1a_scVI_per-midgrain.html

**Contents:**
- Import modules¶
- Parameters¶
- Read in anndata¶
- Subset anndata¶
- Modify mid grained cell type labels: merge CCS and other CMs¶
- Run per condition¶

**Examples:**

Example 1 (python):
```python
# import warnings
# warnings.simplefilter("ignore", UserWarning)

import anndata
import matplotlib.pyplot as plt
import seaborn as sns

import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc

import scvi
```

Example 2 (python):
```python
Global seed set to 0
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/flax/core/frozen_dict.py:169: FutureWarning: jax.tree_util.register_keypaths is deprecated, and will be removed in a future release. Please use `register_pytree_with_keys()` instead.
  jax.tree_util.register_keypaths(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/pytorch_lightning/utilities/warnings.py:53: LightningDeprecationWarning: pytorch_lightning.utilities.warnings.rank_zero_deprecation has been deprecated in v1.6 and will be removed in v1.8. Use the equivalent function from the pytorch_lightning.utilities.rank_zero module instead.
  new_rank_zero_deprecation(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/pytorch_lightning/utilities/warnings.py:58: LightningDeprecationWarning: The `pytorch_lightning.loggers.base.rank_zero_experiment` is deprecated in v1.7 and will be removed in v1.9. Please use `pytorch_lightning.loggers.logger.rank_zero_experiment` instead.
  return new_rank_zero_deprecation(*args, **kwargs)
```

Example 3 (python):
```python
import gc
import torch
```

Example 4 (python):
```python
import session_info
session_info.show()
```

Example 5 (python):
```python
-----
anndata             0.8.0
matplotlib          3.7.1
numpy               1.23.5
pandas              1.5.3
scanpy              1.9.3
scvi                0.19.0
seaborn             0.12.2
session_info        1.0.0
torch               1.13.1+cu117
-----
```

Example 6 (python):
```python
PIL                 9.4.0
absl                NA
asttokens           NA
attr                22.2.0
backcall            0.2.0
certifi             2022.12.07
cffi                1.15.1
charset_normalizer  3.1.0
chex                0.1.6
comm                0.1.2
contextlib2         NA
cycler              0.10.0
cython_runtime      NA
dateutil            2.8.2
debugpy             1.6.6
decorator           5.1.1
defusedxml          0.7.1
deprecate           0.3.2
docrep              0.3.2
etils               1.1.0
executing           1.2.0
flax                0.6.7
fsspec              2023.3.0
google              NA
h5py                3.8.0
idna                3.4
igraph              0.10.4
importlib_metadata  NA
importlib_resources NA
ipykernel           6.21.3
ipython_genutils    0.2.0
ipywidgets          8.0.4
jax                 0.4.10
jaxlib              0.4.10
jedi                0.18.2
joblib              1.2.0
kiwisolver          1.4.4
leidenalg           0.9.1
llvmlite            0.39.1
ml_collections      NA
ml_dtypes           0.2.0
mpl_toolkits        NA
msgpack             1.0.5
mudata              0.2.1
multipledispatch    0.6.0
natsort             8.3.1
numba               0.56.4
numpyro             0.11.0
nvidia              NA
opt_einsum          v3.3.0
optax               0.1.4
packaging           23.0
parso               0.8.3
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
platformdirs        3.1.1
prompt_toolkit      3.0.38
psutil              5.9.4
ptyprocess          0.7.0
pure_eval           0.2.2
pydev_ipython       NA
pydevconsole        NA
pydevd              2.9.5
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.14.0
pyparsing           3.0.9
pyro                1.8.4
pytorch_lightning   1.7.7
pytz                2022.7.1
requests            2.28.2
rich                NA
scipy               1.10.1
setuptools          65.6.3
six                 1.16.0
sklearn             1.2.2
stack_data          0.6.2
statsmodels         0.13.5
tensorboard         2.12.0
texttable           1.6.7
threadpoolctl       3.1.0
toolz               0.12.0
torchmetrics        0.11.4
torchvision         0.14.1+cu117
tornado             6.2
tqdm                4.65.0
traitlets           5.9.0
tree                0.1.8
typing_extensions   NA
urllib3             1.26.15
wcwidth             0.2.6
yaml                6.0
zipp                NA
zmq                 25.0.1
zoneinfo            NA
```

Example 7 (unknown):
```unknown
-----
IPython             8.11.0
jupyter_client      8.0.3
jupyter_core        5.2.0
notebook            6.5.3
-----
Python 3.9.16 (main, Mar  8 2023, 14:00:05) [GCC 11.2.0]
Linux-4.15.0-214-generic-x86_64-with-glibc2.27
-----
Session information updated at 2023-12-29 22:41
```

Example 8 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=80, facecolor='white', color_map = 'RdPu',)
```

Example 9 (python):
```python
path_to_adata_gex = '/nfs/team205/heart/anndata_objects/Foetal/Feb28ObjectRaw_Multiome.h5ad'
celltype_col = 'mid_grain_mod'
model_architecture_conditions = ['one-layer',
              # 'two-layer',
              # 'three-layer'
                                ]
```

Example 10 (python):
```python
adata = sc.read_h5ad(path_to_adata_gex)
adata
```

Example 11 (unknown):
```unknown
AnnData object with n_obs × n_vars = 211145 × 36601
    obs: 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'fine_grain_aCMs_merged', 'fine_grain_aCMs-node_merged'
    var: 'gene_id'
```

Example 12 (python):
```python
adata.X.data[:10]
```

Example 13 (unknown):
```unknown
array([2., 1., 1., 2., 1., 2., 1., 2., 1., 1.], dtype=float32)
```

Example 14 (python):
```python
# read in selected nuclei id
df = pd.read_csv('/nfs/team205/heart/anndata_objects/Foetal/multiome_ATAC/ArchR/GEX_ATAC_comparison/subsampled_nuclei_n1000_29Dec2023.txt',
                 header=None)
nuclei_sel = pd.Index(df[0])
print(len(nuclei_sel))
nuclei_sel[:5]
```

Example 15 (unknown):
```unknown
Index(['7089STDY13216921_BHF_F_Hea13242528_TGGGCCTAGATGGACA-1',
       '7089STDY13216921_BHF_F_Hea13242528_AAAGGCTCAGCTACGT-1',
       '7089STDY13216921_BHF_F_Hea13242528_CATCATAAGCGATACT-1',
       '7089STDY13216921_BHF_F_Hea13242528_CAGGCTATCACCAATA-1',
       '7089STDY13216921_BHF_F_Hea13242528_CTAATGTCACTTCATC-1'],
      dtype='object', name=0)
```

Example 16 (python):
```python
# subset
adata = adata[nuclei_sel]
adata
```

Example 17 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 44136 × 36601
    obs: 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 'fine_grain_aCMs_merged', 'fine_grain_aCMs-node_merged'
    var: 'gene_id'
```

Example 18 (python):
```python
# get indices of CCS cells
a_ccs_indices = adata.obs_names[adata.obs['fine_grain'].isin(['SinoatrialNodeCardiomyocytes','AtrioventricularNodeCardiomyocytes'])]
v_ccs_indices = adata.obs_names[adata.obs['fine_grain'].isin(['VentricularConductionSystemProximal','VentricularConductionSystemDistal'])]

# modify: gex data
adata.obs['mid_grain_mod'] = adata.obs['mid_grain'].astype('str').copy()
adata.obs.replace({'mid_grain_mod':{
    'AtrialCardiomyocytes':'AtrialCardiomyocytes_plusCCS',
    'VentricularCardiomyocytes':'VentricularCardiomyocytes_plusCCS'
}},inplace=True)
adata.obs.loc[a_ccs_indices,'mid_grain_mod'] = 'AtrialCardiomyocytes_plusCCS'
adata.obs.loc[v_ccs_indices,'mid_grain_mod'] = 'VentricularCardiomyocytes_plusCCS'
adata.obs['mid_grain_mod'].value_counts()
```

Example 19 (python):
```python
/tmp/ipykernel_65247/1262357881.py:6: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  adata.obs['mid_grain_mod'] = adata.obs['mid_grain'].astype('str').copy()
```

Example 20 (unknown):
```unknown
LymphoidCells                        7006
Fibroblasts                          6969
VentricularCardiomyocytes_plusCCS    6531
AtrialCardiomyocytes_plusCCS         4381
MyeloidCells                         4321
MuralCells                           3103
BloodVesselEndothelialCells          3028
PericardialCells                     2187
Glia                                 1759
EndocardialCells                     1410
EpicardialCells                      1340
Neurons                              1101
LymphaticEndothelialCells            1000
Name: mid_grain_mod, dtype: int64
```

Example 21 (python):
```python
%%time
for cond in model_architecture_conditions:
    for celltype in set(adata.obs[celltype_col]):
        print(f'##############################')
        print(f'##### {cond}: {celltype} #####')
        print(f'##############################')

        # subset
        adata_sub = adata[adata.obs[celltype_col]==celltype]
        # filter genes
        sc.pp.filter_genes(adata_sub, min_cells=3)

        # setup anndata for scVI
        adata_sub = adata_sub.copy()
        scvi.model.SCVI.setup_anndata(adata_sub, 
                                  # layer="counts", 
                                  categorical_covariate_keys=['batch_key','region'], # added 'region'
                                  continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo',
                                                             'S_score', 'G2M_score'
                                                            ])
        # creating a model
        if cond == 'three-layer':
            vae = scvi.model.SCVI(adata_sub, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
        elif cond == 'two-layer':
            vae = scvi.model.SCVI(adata_sub, n_hidden=128, n_latent=50, n_layers=2, dispersion = 'gene-batch')
        elif cond == 'one-layer':
            vae = scvi.model.SCVI(adata_sub, n_hidden=128, n_latent=50, n_layers=1, dispersion = 'gene-batch')
        print(vae)
        vae.view_anndata_setup(adata_sub)
        # train
        vae.train()

        # save scvi model
        vae.save(f"/nfs/team205/heart/anndata_objects/Foetal/scVI/models/subsets/Foetal_multiome_{celltype}_{cond}_added-cov-region_subsampled-n1000/",overwrite=True)

        # save scVI lagent space
        adata_sub.obsm["X_scVI"] = vae.get_latent_representation()
        adata_sub.write(f'/nfs/team205/heart/anndata_objects/Foetal/scVI/subsets/Foetal_multiome_{celltype}_{cond}_added-cov-region_subsampled-n1000.h5ad')

        # Convergency plot
        vae.history['elbo_train']
        x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
        plt.plot(x, vae.history['elbo_train'], label="train")
        plt.xlabel('epoch')
        plt.ylabel('elbo_train')
        plt.title(f'{cond}: {celltype}')
        plt.show()

        del adata_sub, vae
        
        # free up GPU
        gc.collect()
        torch.cuda.empty_cache()
        print('')
```

Example 22 (unknown):
```unknown
##############################
##### one-layer: LymphaticEndothelialCells #####
##############################
filtered out 15921 genes that are detected in less than 3 cells
```

Example 23 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 5 in adata.obs['batch_key'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 1 in adata.obs['region'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
```

Example 24 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 25 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 26 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 27 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 28 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 1000  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 20680 │
└──────────────────────────┴───────┘
```

Example 29 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 30 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 31 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 32 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │     C104_Nuclei_Multiome-v1     │          5          │
│                        │    Hst33_Nuclei_Multiome-v1     │          6          │
│                        │    Hst36_Nuclei_Multiome-v1     │          7          │
│                        │    Hst39_Nuclei_Multiome-v1     │          8          │
│                        │    Hst40_Nuclei_Multiome-v1     │          9          │
│                        │    Hst41_Nuclei_Multiome-v1     │         10          │
│                        │                                 │                     │
│  adata.obs['region']   │              aorta              │          0          │
│                        │              apex               │          1          │
│                        │              atria              │          2          │
│                        │          atrial septum          │          3          │
│                        │        ductus arteriosus        │          4          │
│                        │          whole sample           │          5          │
│                        │       heart without node        │          6          │
│                        │         left ventricle          │          7          │
│                        │              node               │          8          │
│                        │          outflow tract          │          9          │
│                        │           pericardium           │         10          │
│                        │  pulmonary arches and branches  │         11          │
│                        │         right ventricle         │         12          │
│                        │ right ventricle and papillaries │         13          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 33 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 34 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py:1892: PossibleUserWarning: The number of training batches (8) is smaller than the logging interval Trainer(log_every_n_steps=10). Set a lower value for log_every_n_steps if you want to see logs for the training epoch.
  rank_zero_warn(
```

Example 35 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [01:58<00:00,  5.16it/s, loss=7.65e+03, v_num=1]
```

Example 36 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 37 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [01:58<00:00,  3.37it/s, loss=7.65e+03, v_num=1]
```

Example 38 (unknown):
```unknown
##############################
##### one-layer: LymphoidCells #####
##############################
filtered out 12160 genes that are detected in less than 3 cells
```

Example 39 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 4 in adata.obs['batch_key'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
```

Example 40 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 41 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 42 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 43 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 44 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 7006  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 24441 │
└──────────────────────────┴───────┘
```

Example 45 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 46 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 47 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 48 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │    Hst33_Nuclei_Multiome-v1     │          5          │
│                        │    Hst36_Nuclei_Multiome-v1     │          6          │
│                        │    Hst39_Nuclei_Multiome-v1     │          7          │
│                        │    Hst40_Nuclei_Multiome-v1     │          8          │
│                        │    Hst41_Nuclei_Multiome-v1     │          9          │
│                        │                                 │                     │
│  adata.obs['region']   │              aorta              │          0          │
│                        │              atria              │          1          │
│                        │          atrial septum          │          2          │
│                        │        ductus arteriosus        │          3          │
│                        │          whole sample           │          4          │
│                        │       heart without node        │          5          │
│                        │         left ventricle          │          6          │
│                        │              node               │          7          │
│                        │           pericardium           │          8          │
│                        │  pulmonary arches and branches  │          9          │
│                        │         right ventricle         │         10          │
│                        │ right ventricle and papillaries │         11          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 49 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 50 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 51 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [09:14<00:00,  1.38s/it, loss=4.76e+03, v_num=1]
```

Example 52 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 53 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [09:14<00:00,  1.39s/it, loss=4.76e+03, v_num=1]
```

Example 54 (unknown):
```unknown
##############################
##### one-layer: MuralCells #####
##############################
filtered out 13545 genes that are detected in less than 3 cells
```

Example 55 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 1 in adata.obs['region'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
```

Example 56 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 57 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 58 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 59 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 60 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 3103  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 23056 │
└──────────────────────────┴───────┘
```

Example 61 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 62 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 63 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 64 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │     C104_Nuclei_Multiome-v1     │          5          │
│                        │    Hst33_Nuclei_Multiome-v1     │          6          │
│                        │    Hst36_Nuclei_Multiome-v1     │          7          │
│                        │    Hst39_Nuclei_Multiome-v1     │          8          │
│                        │    Hst40_Nuclei_Multiome-v1     │          9          │
│                        │    Hst41_Nuclei_Multiome-v1     │         10          │
│                        │                                 │                     │
│  adata.obs['region']   │              aorta              │          0          │
│                        │              apex               │          1          │
│                        │              atria              │          2          │
│                        │          atrial septum          │          3          │
│                        │        ductus arteriosus        │          4          │
│                        │          whole sample           │          5          │
│                        │       heart without node        │          6          │
│                        │         left ventricle          │          7          │
│                        │              node               │          8          │
│                        │          outflow tract          │          9          │
│                        │           pericardium           │         10          │
│                        │  pulmonary arches and branches  │         11          │
│                        │         right ventricle         │         12          │
│                        │ right ventricle and papillaries │         13          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 65 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 66 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 67 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [04:05<00:00,  1.62it/s, loss=4.98e+03, v_num=1]
```

Example 68 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 69 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [04:05<00:00,  1.63it/s, loss=4.98e+03, v_num=1]
```

Example 70 (unknown):
```unknown
##############################
##### one-layer: VentricularCardiomyocytes_plusCCS #####
##############################
filtered out 12175 genes that are detected in less than 3 cells
```

Example 71 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
```

Example 72 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 73 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 74 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 75 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 76 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 6531  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 24426 │
└──────────────────────────┴───────┘
```

Example 77 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 78 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 79 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 80 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │     C104_Nuclei_Multiome-v1     │          5          │
│                        │    Hst33_Nuclei_Multiome-v1     │          6          │
│                        │    Hst36_Nuclei_Multiome-v1     │          7          │
│                        │    Hst39_Nuclei_Multiome-v1     │          8          │
│                        │    Hst40_Nuclei_Multiome-v1     │          9          │
│                        │    Hst41_Nuclei_Multiome-v1     │         10          │
│                        │                                 │                     │
│  adata.obs['region']   │              apex               │          0          │
│                        │              atria              │          1          │
│                        │          atrial septum          │          2          │
│                        │          whole sample           │          3          │
│                        │       heart without node        │          4          │
│                        │         left ventricle          │          5          │
│                        │              node               │          6          │
│                        │          outflow tract          │          7          │
│                        │         right ventricle         │          8          │
│                        │ right ventricle and papillaries │          9          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 81 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 82 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 83 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [08:18<00:00,  1.30s/it, loss=6.25e+03, v_num=1]
```

Example 84 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 85 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [08:18<00:00,  1.25s/it, loss=6.25e+03, v_num=1]
```

Example 86 (unknown):
```unknown
##############################
##### one-layer: Glia #####
##############################
filtered out 15066 genes that are detected in less than 3 cells
```

Example 87 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 5 in adata.obs['batch_key'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 8 in adata.obs['region'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
```

Example 88 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 89 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 90 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 91 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 92 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 1759  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 21535 │
└──────────────────────────┴───────┘
```

Example 93 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 94 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 95 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 96 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │     C104_Nuclei_Multiome-v1     │          5          │
│                        │    Hst33_Nuclei_Multiome-v1     │          6          │
│                        │    Hst36_Nuclei_Multiome-v1     │          7          │
│                        │    Hst39_Nuclei_Multiome-v1     │          8          │
│                        │    Hst40_Nuclei_Multiome-v1     │          9          │
│                        │    Hst41_Nuclei_Multiome-v1     │         10          │
│                        │                                 │                     │
│  adata.obs['region']   │              aorta              │          0          │
│                        │              atria              │          1          │
│                        │          atrial septum          │          2          │
│                        │        ductus arteriosus        │          3          │
│                        │          whole sample           │          4          │
│                        │       heart without node        │          5          │
│                        │         left ventricle          │          6          │
│                        │              node               │          7          │
│                        │          outflow tract          │          8          │
│                        │           pericardium           │          9          │
│                        │  pulmonary arches and branches  │         10          │
│                        │         right ventricle         │         11          │
│                        │ right ventricle and papillaries │         12          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 97 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 98 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 99 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [02:20<00:00,  2.89it/s, loss=5.82e+03, v_num=1]
```

Example 100 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 101 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [02:20<00:00,  2.84it/s, loss=5.82e+03, v_num=1]
```

Example 102 (unknown):
```unknown
##############################
##### one-layer: MyeloidCells #####
##############################
filtered out 12311 genes that are detected in less than 3 cells
```

Example 103 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
```

Example 104 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 105 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 106 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 107 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 108 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 4321  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 24290 │
└──────────────────────────┴───────┘
```

Example 109 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 110 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 111 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 112 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │     C104_Nuclei_Multiome-v1     │          5          │
│                        │    Hst33_Nuclei_Multiome-v1     │          6          │
│                        │    Hst36_Nuclei_Multiome-v1     │          7          │
│                        │    Hst39_Nuclei_Multiome-v1     │          8          │
│                        │    Hst40_Nuclei_Multiome-v1     │          9          │
│                        │    Hst41_Nuclei_Multiome-v1     │         10          │
│                        │                                 │                     │
│  adata.obs['region']   │              aorta              │          0          │
│                        │              apex               │          1          │
│                        │              atria              │          2          │
│                        │          atrial septum          │          3          │
│                        │        ductus arteriosus        │          4          │
│                        │          whole sample           │          5          │
│                        │       heart without node        │          6          │
│                        │         left ventricle          │          7          │
│                        │              node               │          8          │
│                        │          outflow tract          │          9          │
│                        │           pericardium           │         10          │
│                        │  pulmonary arches and branches  │         11          │
│                        │         right ventricle         │         12          │
│                        │ right ventricle and papillaries │         13          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 113 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 114 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 115 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [05:34<00:00,  1.15it/s, loss=5.32e+03, v_num=1]
```

Example 116 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 117 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [05:34<00:00,  1.20it/s, loss=5.32e+03, v_num=1]
```

Example 118 (unknown):
```unknown
##############################
##### one-layer: PericardialCells #####
##############################
filtered out 14085 genes that are detected in less than 3 cells
```

Example 119 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 3 in adata.obs['batch_key'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 0 in adata.obs['region'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
```

Example 120 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 121 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 122 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 123 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 124 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 2187  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 22516 │
└──────────────────────────┴───────┘
```

Example 125 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 126 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 127 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 128 (python):
```python
extra_categorical_covs State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃          Categories           ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │    C87_Nuclei_Multiome-v1     │          0          │
│                        │    C92_Nuclei_Multiome-v1     │          1          │
│                        │    C98_Nuclei_Multiome-v1     │          2          │
│                        │    C104_Nuclei_Multiome-v1    │          3          │
│                        │   Hst39_Nuclei_Multiome-v1    │          4          │
│                        │   Hst40_Nuclei_Multiome-v1    │          5          │
│                        │   Hst41_Nuclei_Multiome-v1    │          6          │
│                        │                               │                     │
│  adata.obs['region']   │             aorta             │          0          │
│                        │         atrial septum         │          1          │
│                        │       ductus arteriosus       │          2          │
│                        │         whole sample          │          3          │
│                        │      heart without node       │          4          │
│                        │         outflow tract         │          5          │
│                        │          pericardium          │          6          │
│                        │ pulmonary arches and branches │          7          │
│                        │                               │                     │
└────────────────────────┴───────────────────────────────┴─────────────────────┘
```

Example 129 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 130 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 131 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [02:53<00:00,  2.29it/s, loss=5.98e+03, v_num=1]
```

Example 132 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 133 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [02:53<00:00,  2.31it/s, loss=5.98e+03, v_num=1]
```

Example 134 (unknown):
```unknown
##############################
##### one-layer: BloodVesselEndothelialCells #####
##############################
filtered out 12573 genes that are detected in less than 3 cells
```

Example 135 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
```

Example 136 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 137 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 138 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 139 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 140 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 3028  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 24028 │
└──────────────────────────┴───────┘
```

Example 141 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 142 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 143 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 144 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │     C104_Nuclei_Multiome-v1     │          5          │
│                        │    Hst33_Nuclei_Multiome-v1     │          6          │
│                        │    Hst36_Nuclei_Multiome-v1     │          7          │
│                        │    Hst39_Nuclei_Multiome-v1     │          8          │
│                        │    Hst40_Nuclei_Multiome-v1     │          9          │
│                        │    Hst41_Nuclei_Multiome-v1     │         10          │
│                        │                                 │                     │
│  adata.obs['region']   │              aorta              │          0          │
│                        │              apex               │          1          │
│                        │              atria              │          2          │
│                        │          atrial septum          │          3          │
│                        │        ductus arteriosus        │          4          │
│                        │          whole sample           │          5          │
│                        │       heart without node        │          6          │
│                        │         left ventricle          │          7          │
│                        │              node               │          8          │
│                        │          outflow tract          │          9          │
│                        │           pericardium           │         10          │
│                        │  pulmonary arches and branches  │         11          │
│                        │         right ventricle         │         12          │
│                        │ right ventricle and papillaries │         13          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 145 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 146 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 147 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [03:59<00:00,  1.74it/s, loss=6.45e+03, v_num=1]
```

Example 148 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 149 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [03:59<00:00,  1.67it/s, loss=6.45e+03, v_num=1]
```

Example 150 (unknown):
```unknown
##############################
##### one-layer: EndocardialCells #####
##############################
filtered out 15447 genes that are detected in less than 3 cells
```

Example 151 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
```

Example 152 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 153 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 154 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 155 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 156 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 1410  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 21154 │
└──────────────────────────┴───────┘
```

Example 157 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 158 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 159 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 160 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │     C104_Nuclei_Multiome-v1     │          5          │
│                        │    Hst33_Nuclei_Multiome-v1     │          6          │
│                        │    Hst36_Nuclei_Multiome-v1     │          7          │
│                        │    Hst39_Nuclei_Multiome-v1     │          8          │
│                        │    Hst40_Nuclei_Multiome-v1     │          9          │
│                        │    Hst41_Nuclei_Multiome-v1     │         10          │
│                        │                                 │                     │
│  adata.obs['region']   │              aorta              │          0          │
│                        │              apex               │          1          │
│                        │              atria              │          2          │
│                        │          atrial septum          │          3          │
│                        │          whole sample           │          4          │
│                        │       heart without node        │          5          │
│                        │         left ventricle          │          6          │
│                        │              node               │          7          │
│                        │          outflow tract          │          8          │
│                        │         right ventricle         │          9          │
│                        │ right ventricle and papillaries │         10          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 161 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 162 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 163 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [01:50<00:00,  3.57it/s, loss=6.83e+03, v_num=1]
```

Example 164 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=400` reached.
```

Example 165 (unknown):
```unknown
Epoch 400/400: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [01:50<00:00,  3.61it/s, loss=6.83e+03, v_num=1]
```

Example 166 (unknown):
```unknown
##############################
##### one-layer: EpicardialCells #####
##############################
filtered out 13029 genes that are detected in less than 3 cells
```

Example 167 (python):
```python
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scanpy/preprocessing/_simple.py:251: ImplicitModificationWarning: Trying to modify attribute `.var` of view, initializing view as actual.
  adata.var['n_cells'] = number
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/scvi/data/_utils.py:168: UserWarning: Category 13 in adata.obs['region'] has fewer than 3 cells. Models may not train properly.
  warnings.warn(
```

Example 168 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 1, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 169 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 170 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 171 (unknown):
```unknown
{
│   'layer': None,
│   'batch_key': None,
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': ['batch_key', 'region'],
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo', 'S_score', 'G2M_score']
}
```

Example 172 (unknown):
```unknown
Summary Statistics         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃     Summary Stat Key     ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│         n_batch          │   1   │
│         n_cells          │ 1340  │
│ n_extra_categorical_covs │   2   │
│ n_extra_continuous_covs  │   5   │
│         n_labels         │   1   │
│          n_vars          │ 23572 │
└──────────────────────────┴───────┘
```

Example 173 (python):
```python
Data Registry                             
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃      Registry Key      ┃            scvi-tools Location             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X            │                  adata.X                   │
│         batch          │          adata.obs['_scvi_batch']          │
│ extra_categorical_covs │ adata.obsm['_scvi_extra_categorical_covs'] │
│ extra_continuous_covs  │ adata.obsm['_scvi_extra_continuous_covs']  │
│         labels         │         adata.obs['_scvi_labels']          │
└────────────────────────┴────────────────────────────────────────────┘
```

Example 174 (python):
```python
batch State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃     Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_batch'] │     0      │          0          │
└──────────────────────────┴────────────┴─────────────────────┘
```

Example 175 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 176 (python):
```python
extra_categorical_covs State Registry                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃           Categories            ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │     C82_Nuclei_Multiome-v1      │          0          │
│                        │     C85_Nuclei_Multiome-v1      │          1          │
│                        │     C87_Nuclei_Multiome-v1      │          2          │
│                        │     C92_Nuclei_Multiome-v1      │          3          │
│                        │     C98_Nuclei_Multiome-v1      │          4          │
│                        │     C104_Nuclei_Multiome-v1     │          5          │
│                        │    Hst33_Nuclei_Multiome-v1     │          6          │
│                        │    Hst36_Nuclei_Multiome-v1     │          7          │
│                        │    Hst39_Nuclei_Multiome-v1     │          8          │
│                        │    Hst40_Nuclei_Multiome-v1     │          9          │
│                        │    Hst41_Nuclei_Multiome-v1     │         10          │
│                        │                                 │                     │
│  adata.obs['region']   │              aorta              │          0          │
│                        │              apex               │          1          │
│                        │              atria              │          2          │
│                        │          atrial septum          │          3          │
│                        │        ductus arteriosus        │          4          │
│                        │          whole sample           │          5          │
│                        │       heart without node        │          6          │
│                        │         left ventricle          │          7          │
│                        │              node               │          8          │
│                        │          outflow tract          │          9          │
│                        │           pericardium           │         10          │
│                        │  pulmonary arches and branches  │         11          │
│                        │         right ventricle         │         12          │
│                        │ right ventricle and papillaries │         13          │
│                        │                                 │                     │
└────────────────────────┴─────────────────────────────────┴─────────────────────┘
```

Example 177 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
│     adata.obs['S_score']     │
│    adata.obs['G2M_score']    │
└──────────────────────────────┘
```

Example 178 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 179 (unknown):
```unknown
Epoch 264/400:  66%|████████████████████████████████████████████████████████████████████████████████████████████▍                                               | 264/400 [01:16<00:38,  3.51it/s, loss=9.89e+03, v_num=1]
```

Example 180 (python):
```python
len(set(adata.obs[celltype_col]))
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Leukocytes/No2_Immune_post-scVI.html

**Contents:**
- Import modules¶
- Function¶
- Read in data¶
- Log-normalise¶
- Clustering, UMAP¶
  - Deciding resolution¶
- Marker gene expressions¶
- DEG analysis¶
- Annotation¶
- Recover row counts and save¶
- Celltypist, pan-foetal immune¶

gene expression: normalise + logtransform

**Examples:**

Example 1 (python):
```python
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import matplotlib.pyplot as plt
import anndata


import celltypist
from celltypist import models

import sctk
import os
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
-----
anndata             0.8.0
celltypist          0.1.9
matplotlib          3.5.2
numpy               1.21.5
pandas              1.3.5
scanpy              1.8.2
sctk                NA
session_info        1.0.0
-----
```

Example 4 (python):
```python
PIL                 9.1.1
asciitree           NA
backcall            0.2.0
beta_ufunc          NA
binom_ufunc         NA
brotli              NA
cached_property     1.5.1
cairo               1.20.0
certifi             2020.12.05
cffi                1.14.4
chardet             3.0.4
charset_normalizer  2.0.10
cloudpickle         1.6.0
colorama            0.4.4
cycler              0.10.0
cython_runtime      NA
cytoolz             0.11.2
dask                2022.01.0
dateutil            2.8.1
decorator           4.4.2
defusedxml          0.6.0
fasteners           0.17.3
fsspec              2022.01.0
google              NA
h5py                3.1.0
idna                2.10
igraph              0.10.2
importlib_metadata  1.7.0
ipykernel           5.4.2
ipython_genutils    0.2.0
ipywidgets          7.6.3
jedi                0.17.2
jinja2              3.1.2
joblib              1.0.0
kiwisolver          1.3.1
leidenalg           0.9.0
llvmlite            0.35.0
louvain             0.7.0
markupsafe          2.1.1
mpl_toolkits        NA
msgpack             1.0.3
natsort             7.1.0
nbinom_ufunc        NA
numba               0.52.0
numcodecs           0.9.1
numexpr             2.7.2
numpy_groupies      0.9.13
packaging           21.3
parso               0.7.1
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
plotly              5.10.0
prompt_toolkit      3.0.10
psutil              5.9.0
ptyprocess          0.7.0
pyarrow             9.0.0
pygments            2.13.0
pyparsing           2.4.7
pytz                2020.5
requests            2.27.1
scipy               1.7.3
scvelo              0.2.4
seaborn             0.11.1
setuptools_scm      NA
sinfo               0.3.1
six                 1.14.0
sklearn             1.0.2
socks               1.7.1
sphinxcontrib       NA
statsmodels         0.12.1
storemagic          NA
tables              3.6.1
tblib               1.7.0
texttable           1.6.3
threadpoolctl       2.1.0
tlz                 0.11.2
toolz               0.11.2
tornado             6.1
traitlets           5.0.5
typing_extensions   NA
urllib3             1.26.9
wcwidth             0.2.5
yaml                5.4.1
zarr                2.11.3
zipp                NA
zmq                 21.0.1
zope                NA
```

Example 5 (unknown):
```unknown
-----
IPython             7.19.0
jupyter_client      6.1.11
jupyter_core        4.7.0
notebook            6.2.0
-----
Python 3.7.9 | packaged by conda-forge | (default, Dec  9 2020, 21:08:20) [GCC 9.3.0]
Linux-4.15.0-112-generic-x86_64-with-debian-bullseye-sid
-----
Session information updated at 2023-02-17 14:35
```

Example 6 (python):
```python
sc.settings.set_figure_params(dpi=120, facecolor='white', color_map = 'RdPu',)
```

Example 7 (python):
```python
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# extract rank_genes_groups result 
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

import scanpy as sc
import pandas as pd

def rank_genes_groups_to_df(adata, cell):
    
    dic = adata.uns['rank_genes_groups'] 
    
    df = pd.DataFrame({
        'names' : dic['names'][cell],
        'scores' : dic['scores'][cell],
        'pvals' : dic['pvals'][cell],
        'pvals_adj' : dic['pvals_adj'][cell],
        'logfoldchanges' : dic['logfoldchanges'][cell]
    })
    
    return df
```

Example 8 (python):
```python
adata = sc.read_h5ad('/home/jovyan/mount/gdrive/Colab/data/scVI/subsets/RNA_foetal_raw_immune_post-scVI_16Feb2023.h5ad')
adata
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 41881 × 31326
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester'
    var: 'gene_name_scRNA-0', 'gene_id', 'n_cells'
    uns: '2Jan_fine_grain_colors', '2Jan_mid_grain_colors', 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'donor_colors', 'leiden_scVI_colors', 'modality_colors', 'sex_colors', 'trimester_colors', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 10 (python):
```python
# normalise and logtransform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
```

Example 11 (python):
```python
%%time
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata, min_dist=0.2, spread=1.0, n_components=3)
sc.tl.leiden(adata, resolution=2, key_added='leiden_scVI')
```

Example 12 (unknown):
```unknown
CPU times: user 1min 45s, sys: 44.8 s, total: 2min 30s
Wall time: 1min 17s
```

Example 13 (python):
```python
sc.pl.umap(adata, color=['leiden_scVI'], size=5, wspace=0.1, legend_loc='on data', legend_fontsize=10,components='all')
```

Example 14 (python):
```python
sc.pl.umap(adata, color=['region','donor','cell_or_nuclei','kit_10x'], size=5, wspace=0.7)
```

Example 15 (python):
```python
pd.crosstab(adata.obs['cell_or_nuclei'],adata.obs['donor']).T
```

Example 16 (python):
```python
sc.pl.umap(adata, color=['2Jan_fine_grain','week'], size=5, wspace=0.1, legend_loc='on data', legend_fontsize=5)
```

Example 17 (python):
```python
set(adata.obs['2Jan_fine_grain'])
```

Example 18 (unknown):
```unknown
{'B1Cells',
 'BCells',
 'BProCells',
 'Cardiofibromyocytes',
 'CardiofibromyocytesSecretory',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronaryVesselAdventitialFibroblasts',
 'CoronaryVesselSmoothMuscleCells',
 'DC1',
 'DC2',
 'DCsMature',
 'DCsPlasmocytoids',
 'EarlyGreatVesselFLRT2',
 'EarlyGreatVesselHOXB4',
 'EndocardialCells',
 'GVAdFibOCA2',
 'GVAdFibOther',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'InnateLymphoidCells',
 'LymphaticEndothelialCells',
 'MacrophagesCX3CR1pos',
 'MacrophagesInflammasome',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MacrophagesTREM2pos',
 'MastCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocIntFibROBO2',
 'MyocIntFibSLIT3',
 'Myofibroblasts',
 'NaturalKillerCells',
 'SchwannCells',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'Tregs',
 'ValveOther',
 'ValvePENK',
 nan}
```

Example 19 (python):
```python
sc.pl.umap(adata, color=['2Jan_fine_grain'], groups='DCsPlasmocytoids', size=5, wspace=0.1, legend_loc='on data', legend_fontsize=5)
```

Example 20 (python):
```python
sc.pl.umap(adata, color=['scrublet_score','cluster_scrublet_score','doublet_pval','doublet_bh_pval','pct_counts_mt','pct_counts_ribo'], size=2, wspace=0.2, ncols=6)
```

Example 21 (python):
```python
'''
# set symbol as var_names
adata.var.set_index('gene_name_multiome-1',inplace=True)
adata.var_names = adata.var_names.astype('str')
adata.var_names_make_unique()
'''
```

Example 22 (python):
```python
# Checking glabal markers
markers = {
    'vCM': ['MYH7', 'MYL2', 'FHL2'],
    'aCM': ['NPPA', 'MYL7', 'MYL4'],
    'FB': ['DCN', 'GCN', 'PDGFRA'],
    'EC': ['VWF', 'PECAM1', 'CDH5'],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby='leiden_scVI')
sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 23 (python):
```python
WARNING: You’re trying to run this on 31326 dimensions of `.X`, if you really want this, set `use_rep='X'`.
         Falling back to preprocessing with `sc.pp.pca` and default params.
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: vCM, aCM, FB, etc.
```

Example 24 (python):
```python
# lymphocytes markers

markers={
    'B cell': ['CD19', 'CD79A', 'CD79B', 'IGHM', 'IGHG1', 'IGHA1'],
    'T cell': ['CD3E', 'CD3D', 'TRAC', 'CD4', 'CD8A', 'CD8B'],
    'naive': ['CCR7', 'TCF7', 'LEF1', 'SELL'],
    'act': ['IL2','CD69'],
    'CD4T_reg': ['FOXP3', 'CTLA4', 'IL2RA', 'IKZF2'],
    'cytotoxic': ['PRF1', 'GZMB', 'GZMH', 'NKG7'],
    'trans': ['GZMK', 'TOX'],
    'te': ['TIGIT', 'LAG3', 'PDCD1'],
    'em': ['IL7R', 'RUNX2'],
    'MAIT': ['SLC4A10', 'KLRB1', 'CCR6'],
    'NK': ['KLRF1', 'KLRD1', 'NCAM1', 'FCGR3A'],
    'ILC': ['KIT', 'IL18R1'],
    'cycling': ['MKI67', 'TOP2A', 'UBE2C'],
    'TFs': ['TBX21', 'GATA3', 'RORC', 'BCL6',],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 25 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: B cell, T cell, naive, etc.
```

Example 26 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B','TRAC','TRBC1','TRDC','TRGC1'],
    'naive': ['TCF7', 'LEF1', 'SELL'],
    'cytotoxic': ['PRF1', 'GZMB', 'GZMH', 'NKG7'],
    'NK': ['KLRF1', 'KLRD1', 'NCAM1','FCGR3A','IFNG'],
    'ILC3': ['KIT', 'IL18R1','RORC','IL17A'],
    
    'Mono':['CCR2','CD14','FCGR3A','CX3CR1','FCGR1A','FCN1','TREM2'],
    'MP':['C1QA','C1QB','CD68','CD163','MERTK','LYVE1','IGF1','TIMD4','DOCK4'],
    'DC':['FLT3','FCER1A','CD1C','HLA-DPA1','HLA-DPB1','CCR7'],
    'DC1':['ID2','IRF8','BATF3','CLEC9A'],
    'DC2':['CLEC10A','CD1C','FCER1A',],
    'Neutro':['MYB', 'MPO', 'CEACAM8','CXCR1','CXCR2'],
    
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1','IL7R',],
    '':['CCR7','TNFRSF13B',],
    'ProB':['KIT','SPN','CD34'],
    'Plasma': ['CD27','CCR10','CD38','SDC1','JCAIN'],
    'Abs':['IGHM','IGHD', 'IGHG1','IGHG2', 'IGHG3','IGHG4', 'IGHA1','IGHE','IGLC1','IGKC'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    
    
    'Cycling':['MKI67','TOP2A'],

    'TFs': ['TBX21', 'GATA3', 'RORC', 'BCL6',],
    'Mast': ['KIT', 'CPA3'],
    'Megakaryocyte':['ITGA2B','MPL','ITGB3', 'TUBB1', 'PPBP'],
    'pDC':['IRF8','IRF4','IL3RA']
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 27 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: T cell, naive, cytotoxic, etc.
```

Example 28 (python):
```python
sc.settings.set_figure_params(dpi=120, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=['CCR2','CD14','FCGR3A','CX3CR1','FCGR1A','FCN1','TREM2',
                'C1QA','C1QB','CD68','CD163','MERTK','LYVE1','IGF1','TIMD4','FOLR2','DOCK4',
                'FLT3','FCER1A','CD1C','HLA-DPA1','HLA-DPB1',
                'CD3D','CD3E','CD4','CD8A','CD8B','CD19','CD19','CD22','CD79A', 'CD79B','MKI67','TOP2A',], size=20, wspace=0.2, ncols=6, components='all')
```

Example 29 (python):
```python
adata.X.data[:10]
```

Example 30 (unknown):
```unknown
array([0.20843568, 0.38083044, 0.20843568, 0.20843568, 0.20843568,
       0.38083044, 0.38083044, 0.76952875, 0.38083044, 0.38083044],
      dtype=float32)
```

Example 31 (python):
```python
sc.tl.rank_genes_groups(adata, 'leiden_scVI', method='t-test')

DEG_dict = {}
for cluster in adata.obs['leiden_scVI'].cat.categories:
    df=rank_genes_groups_to_df(adata, cluster)
    # select genes: significant and up-regulated ones
    df=df[(df['pvals_adj']<0.05)&(df['logfoldchanges']>0)]
    # sort based on the logFC
    df.sort_values('scores',ascending=False,inplace=True)
    DEG_dict[cluster]=list(df[:5]['names'])
    del df

sc.pl.dotplot(adata,
              DEG_dict, 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 32 (python):
```python
# marker of cluster 44
# migratory DC?
DEG_dict = {}
for cluster in adata.obs['leiden_scVI'].cat.categories:
    df=rank_genes_groups_to_df(adata, cluster)
    # select genes: significant and up-regulated ones
    df=df[(df['pvals_adj']<0.05)&(df['logfoldchanges']>0)]
    # sort based on the logFC
    df.sort_values('scores',ascending=False,inplace=True)
    DEG_dict[cluster]=list(df[:50]['names'])
    del df

sc.pl.dotplot(adata,
              DEG_dict['42']+['FLT3','ID2','IRF4','IRF8','CCR7','CIITA','PTPRC'], 
              groupby='leiden_scVI',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 33 (python):
```python
sc.pl.umap(adata, color=['leiden_scVI'], size=3, wspace=0.1, legend_loc='on data', legend_fontsize=5, legend_fontweight='normal')
# components='all',
```

Example 34 (python):
```python
sc.pl.umap(adata, color=['leiden_scVI'], groups=['32'], size=5, wspace=0.1, legend_loc='on data', legend_fontsize=7)
```

Example 35 (python):
```python
adata.obs['cell_type2']=adata.obs['leiden_scVI'].astype('str').copy()
adata.obs.replace({'cell_type2':{
    '0':'Lymphoid', 
    '1':'Myeloid', 
    '2':'Myeloid', 
    '3':'Lymphoid', 
    '4':'Lymphoid', 
    '5':'Myeloid',  
    '6':'Lymphoid', 
    '7':'Lymphoid',  
    '8':'Lymphoid', 
    '9':'Lymphoid',  
    '10':'Myeloid',  
    '11':'Myeloid',  
    '12':'Lymphoid', 
    '13':'Myeloid', 
    '14':'Lymphoid', 
    '15':'Myeloid', 
    '16':'Myeloid', 
    '17':'Lymphoid', 
    '18':'Myeloid', 
    '19':'Myeloid', 
    '20':'Myeloid', 
    '21':'Lymphoid', 
     '22':'Lymphoid', 
     '23':'Mast cell', 
     '24':'Lymphoid', 
     '25':'Lymphoid', 
     '26':'Myeloid', 
    '27':'Myeloid', 
    '28':'Lymphoid', 
    '29':'Myeloid', 
    '30':'Lymphoid', 
    '31':'Myeloid', 
    '32':'Myeloid', 
    '33':'Lymphoid', 
    '34':'Lymphoid', 
    '35':'Plasmacytoid DC',  
    '36':'Myeloid', 
    '37':'Myeloid', 
    '38':'Lymphoid', 
    '39':'Lymphoid', 
    '40':'Megakaryocyte', 
    '41':'Lymphoid', 
    '42':'DC_mature', 
    '43':'Plasmacytoid DC', 
}}, inplace=True)


adata.obs['cell_type2']=adata.obs['cell_type2'].astype('category')
adata.obs['cell_type2'].cat.reorder_categories([
   'Lymphoid', 
    'Myeloid',
    'Plasmacytoid DC',
    # 'DC1',
    'DC_mature',
    'Megakaryocyte',
     'Mast cell',
    # 'Doublet',
], inplace=True)

adata.obs['cell_type2'].value_counts()
```

Example 36 (unknown):
```unknown
Lymphoid           21336
Myeloid            18527
Mast cell            866
Plasmacytoid DC      608
Megakaryocyte        360
DC_mature            184
Name: cell_type2, dtype: int64
```

Example 37 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','CD4', 'CD8A', 'CD8B','TRAC','TRBC1','TRDC','TRGC1'],
    'naive': ['TCF7', 'LEF1', 'SELL'],
    'cytotoxic': ['PRF1', 'GZMB', 'GZMH', 'NKG7'],
    'NK': ['KLRF1', 'KLRD1', 'NCAM1','FCGR3A','IFNG'],
    'ILC3': ['KIT', 'IL18R1','RORC','IL17A'],
    
    'Mono':['CCR2','CD14','FCGR3A','CX3CR1','FCGR1A','FCN1','TREM2'],
    'MP':['C1QA','C1QB','CD68','CD163','MERTK','LYVE1','IGF1','TIMD4','CX3CR1','DOCK4','COL1A1','COL1A2','COL3A1'],
    'DC':['FLT3','FCER1A','CD1C','HLA-DPA1','HLA-DPB1','CCR7'],
    'DC1':['ID2','IRF8','BATF3','CLEC9A'],
    'DC2':['CLEC10A','CD1C','FCER1A',],
    'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'Neutro':['MYB', 'MPO', 'CEACAM8','CXCR1','CXCR2'],
    
    'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1','IL7R',],
    '':['CCR7','TNFRSF13B',],
    'ProB':['KIT','SPN','CD34'],
    'Plasma': ['CD27','CCR10','CD38','SDC1','JCAIN'],
    'Abs':['IGHM','IGHD', 'IGHG1','IGHG2', 'IGHG3','IGHG4', 'IGHA1','IGHE','IGLC1','IGKC'],
    'Gene editing': ['AICDA', 'RAG1','RAG2'],
    
     'pDC':['IRF8','IRF4','IL3RA'],
    
    

    'TFs': ['TBX21', 'GATA3', 'RORC', 'BCL6',],
    'Mast': ['KIT', 'CPA3','HDC','GATA2'],
    'Megakaryocyte':['ITGA2B','MPL','ITGB3', 'TUBB1', 'PPBP'],
    'Cycling':['MKI67','TOP2A'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='cell_type2',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 38 (python):
```python
markers={
     'T cell': ['CD3E', 'CD3D','TRAC','TRBC1',],
     'B': ['CD19','CD20','CD22','CD79A', 'CD79B','MS4A1','IL7R',],
   
    
    'Mono':['CCR2','CD14','FCGR3A','CX3CR1','FCGR1A','FCN1','TREM2'],
    'MP':['C1QA','C1QB','CD68','CD163','MERTK','LYVE1','IGF1','TIMD4','CX3CR1','DOCK4','COL1A1','COL1A2','COL3A1'],
    'DC1':['ID2','IRF8','BATF3','CLEC9A'],
    'DC2':['CLEC10A','CD1C','FCER1A',],
     'DC_mature':['FLT3', 'CCR7','LAMP3', 'IL15', 'CD83', 'LY75', ],
    'pDC':['IRF8','IRF4','IL3RA'],
    
   
    'Mast': ['KIT', 'CPA3','HDC','GATA2'],
    'Megakaryocyte':['ITGA2B','MPL','ITGB3',],
    'mesenchymalMP':['COL1A1','COL1A2','COL3A1','C1QA','C1QC','C1QD','VSIG4','COL3A1', 'MDK', 'SPARC', 'ELN'],
    'vCM': ['MYH7', 'MYL2', 'FHL2'],
    'aCM': ['NPPA', 'MYL7', 'MYL4'],
}


for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.pl.dotplot(adata,
              markers, 
              groupby='cell_type2',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 39 (python):
```python
sc.settings.set_figure_params(dpi=120,  color_map = 'RdPu',)
sc.pl.umap(adata, color=['cell_type2'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 40 (python):
```python
sc.pl.umap(adata, color=['cell_type2'], groups='Myeloid', size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 41 (python):
```python
sc.pl.umap(adata, color=['cell_type2'], groups='Lymphoid', size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 42 (python):
```python
sc.tl.rank_genes_groups(adata, 'cell_type2', method='t-test')

DEG_dict = {}
for cluster in adata.obs['cell_type2'].cat.categories:
    df=rank_genes_groups_to_df(adata, cluster)
    # select genes: significant and up-regulated ones
    df=df[(df['pvals_adj']<0.05)&(df['logfoldchanges']>0)]
    # sort based on the logFC
    df.sort_values('scores',ascending=False,inplace=True)
    DEG_dict[cluster]=list(df[:10]['names'])
    del df

sc.pl.dotplot(adata,
              DEG_dict, 
              groupby='cell_type2',
              dendrogram=False,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 43 (python):
```python
adata_raw=sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/14Feb_fromSemih/14FebImmuneForKazumasa.h5ad')
print(adata_raw.shape)

adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp # from annotated or subsetted data
                               )
print(adata_raw.shape)
```

Example 44 (unknown):
```unknown
(49042, 36601)
(41881, 36601)
```

Example 45 (python):
```python
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/Immune/RNA_foetal_raw_immune_16Feb2023.h5ad')
adata_raw
```

Example 46 (unknown):
```unknown
AnnData object with n_obs × n_vars = 41881 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester', 'cell_type2'
    var: 'gene_name_scRNA-0', 'gene_id'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding', 'X_pca'
    obsp: 'connectivities', 'distances'
```

Example 47 (python):
```python
# save to gdrive
# update RNA_foetal_raw_immune_16Feb2023.h5ad
adata_raw.write('/home/jovyan/mount/gdrive/Colab/data/anndata/RNA_foetal_raw_immune_16Feb2023.h5ad')
```

Example 48 (python):
```python
sc.pl.umap(adata_raw, color=['cell_type2'], size=5, legend_fontsize=10, frameon=False, components='all', wspace=0.5)
```

Example 49 (python):
```python
adata_raw.obs['cell_type2'].value_counts()
```

Example 50 (unknown):
```unknown
# load model
panfetal_model = models.Model.load('/nfs/team205/kk18/Analysis/celltypist/models/celltypist_model.Pan_Fetal_Human.pkl')
```

Example 51 (python):
```python
prediction=celltypist.annotate(adata, model = panfetal_model, majority_voting = False)
```

Example 52 (unknown):
```unknown
celltypist.dotplot(prediction, use_as_reference = 'cell_type2', use_as_prediction = 'predicted_labels')
```

Example 53 (python):
```python
adata_pre = sc.read_h5ad('/home/jovyan/mount/gdrive/Colab/data/anndata/RNA_foetal_raw_immune_4Feb2023.h5ad')
adata_pre
```

Example 54 (unknown):
```unknown
AnnData object with n_obs × n_vars = 42624 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'immune', 'age_pcw', 'week_pcw', 'cell_type2'
    var: 'gene_name_scRNA-0', 'gene_name_multiome-1'
    uns: 'cell_type2_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 55 (python):
```python
pd.crosstab(adata_pre.obs['cell_type2'],adata_pre.obs['week_pcw'])
```

Example 56 (python):
```python
pd.crosstab(adata_raw.obs['cell_type2'],adata_raw.obs['week'])
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no03-2_harmony_clustering.html

**Contents:**
- Read in¶
- Clustering¶
- Save¶

**Examples:**

Example 1 (python):
```python
import scanpy as sc
import numpy as np
import pandas as pd
import os
# import rapids_singlecell as rsc
from tqdm import tqdm

import matplotlib.pyplot as plt
import seaborn as sns
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
sc.settings.set_figure_params(dpi=120)
```

Example 4 (python):
```python
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
adata
```

Example 5 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 6 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','tissue_block_id'], wspace=0.3, cmap='RdPu')
```

Example 7 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['celltypist_mid_fin'], wspace=0.2, cmap='RdPu')
```

Example 8 (python):
```python
%%time
latent_space='pca_harmony'
leiden_keys=[]
for res in tqdm([0.2,0.3,0.4,0.5,0.8,1.0,1.5,2.0,3.0]):
    leiden_key = f"leiden_{res}"
    key_added=f"{latent_space}_{leiden_key}"
    sc.tl.leiden(adata,neighbors_key=latent_space,resolution=res,key_added=key_added)
    leiden_keys.append(key_added)
```

Example 9 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",
                color=leiden_keys,wspace=0.3,ncols=5)
```

Example 10 (python):
```python
adata.write(path_adata)
adata
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Endothelial/CoronaryCellCyclingscFates.html

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-09-19 14:34.
```

Example 5 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(297473, 36601)
```

Example 7 (python):
```python
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodeCardiomyocytes':'#854834',
    'AtrioventricularNodeCardiomyocytes':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts1':'#8a6800',
    'MyocardialInterstitialFibroblasts2':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCells1':'#c95e00',
    'PericardialCells2':'#01e077',
    'PericardialCells3':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)
```

Example 8 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 9 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 10 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 11 (python):
```python
set(adata.obs.fine_grain)
```

Example 12 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParasympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 13 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adata=adata[adata.obs.cycling=='no',:].copy()
```

Example 14 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 15 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 16 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
print(adata.shape)
```

Example 17 (unknown):
```unknown
(8375, 36601)
```

Example 18 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
```

Example 19 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:08)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1332
```

Example 20 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'MCM2', 'MCM4', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'UHRF1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    329 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'CKAP2L', 'ANP32E', 'HJURP', 'CDCA3', 'NCAPD2', 'CDCA2', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    729 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 21 (python):
```python
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/torchmetrics/utilities/prints.py:36: UserWarning: Torchmetrics v0.9 introduced a new argument class property called `full_state_update` that has
                not been set for this class (ElboMetric). The property determines if `update` by
                default needs access to the full metric state. If this is not the case, significant speedups can be
                achieved and we recommend setting this to `False`.
                We provide an checking function
                `from torchmetrics.utilities import check_forward_no_full_state`
                that can be used to check if the `full_state_update=True` (old and potential slower behaviour,
                default for now) or if `full_state_update=False` can be used safely.
                
  warnings.warn(*args, **kwargs)
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 22 (unknown):
```unknown
Epoch 1/50:   0%|                                        | 0/50 [00:00<?, ?it/s]
```

Example 23 (python):
```python
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/torchmetrics/utilities/prints.py:36: UserWarning: Torchmetrics v0.9 introduced a new argument class property called `full_state_update` that has
                not been set for this class (ResultMetric). The property determines if `update` by
                default needs access to the full metric state. If this is not the case, significant speedups can be
                achieved and we recommend setting this to `False`.
                We provide an checking function
                `from torchmetrics.utilities import check_forward_no_full_state`
                that can be used to check if the `full_state_update=True` (old and potential slower behaviour,
                default for now) or if `full_state_update=False` can be used safely.
                
  warnings.warn(*args, **kwargs)
```

Example 24 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:30<00:00,  1.66it/s, loss=676, v_num=1]
```

Example 25 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    479 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBE1', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    244 total control genes are used. (0:00:00)
computing neighbors
```

Example 26 (python):
```python
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/numba/core/typed_passes.py:313: NumbaPerformanceWarning: 
The keyword argument 'parallel=True' was specified but no transformation for parallel execution was possible.

To find out why, try turning on parallel diagnostics, see https://numba.pydata.org/numba-doc/latest/user/parallel.html#diagnostics for help.

File "../../miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/rp_tree.py", line 135:
@numba.njit(fastmath=True, nogil=True, parallel=True)
def euclidean_random_projection_split(data, indices, rng_state):
^

  warnings.warn(errors.NumbaPerformanceWarning(msg,
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/nndescent.py:91: NumbaPerformanceWarning: 
The keyword argument 'parallel=True' was specified but no transformation for parallel execution was possible.

To find out why, try turning on parallel diagnostics, see https://numba.pydata.org/numba-doc/latest/user/parallel.html#diagnostics for help.

File "../../miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/utils.py", line 409:
@numba.njit(parallel=True)
def build_candidates(current_graph, n_vertices, n_neighbors, max_candidates, rng_state):
^

  candidate_neighbors = build_candidates(
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/numba/core/typed_passes.py:313: NumbaPerformanceWarning: 
The keyword argument 'parallel=True' was specified but no transformation for parallel execution was possible.

To find out why, try turning on parallel diagnostics, see https://numba.pydata.org/numba-doc/latest/user/parallel.html#diagnostics for help.

File "../../miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/nndescent.py", line 47:
    @numba.njit(parallel=True)
    def nn_descent(
    ^

  warnings.warn(errors.NumbaPerformanceWarning(msg,
```

Example 27 (python):
```python
finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:03)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:05)
```

Example 28 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/anndata.py:1220: FutureWarning: The `inplace` parameter in pandas.Categorical.reorder_categories is deprecated and will be removed in a future version. Removing unused categories will always return a new Categorical object.
  c.reorder_categories(natsorted(c.categories), inplace=True)
... storing 'phase' as categorical
```

Example 29 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 30 (python):
```python
sc.tl.diffmap(adata)
sc.pl.diffmap(adata, color='fine_grain')
sc.pl.diffmap(adata, color='cycling')
```

Example 31 (python):
```python
computing Diffusion Maps using n_comps=15(=n_dcs)
computing transitions
    finished (0:00:00)
    eigenvalues of transition matrix
    [1.         0.99651    0.9899577  0.9877106  0.9849084  0.9792807
     0.97557443 0.9727674  0.9723406  0.97022986 0.9688626  0.9665088
     0.96357495 0.96243817 0.95802355]
    finished: added
    'X_diffmap', diffmap coordinates (adata.obsm)
    'diffmap_evals', eigenvalues of transition matrix (adata.uns) (0:00:00)
```

Example 32 (python):
```python
#adata.write('./CoronaryEndothelialCellsscFates.h5ad')
```

Example 33 (python):
```python
import pandas as pd
import numpy as np
import anndata


import scipy
import matplotlib.pyplot as plt
import scanpy as sc
import scFates as scf
import palantir

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42
plt.rcParams["font.family"] = "sans-serif"
sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 
import matplotlib.pyplot as plt
import matplotlib.font_manager

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 34 (unknown):
```unknown
findfont: Font family ['Raleway'] not found. Falling back to DejaVu Sans.
```

Example 35 (unknown):
```unknown
Running Scanpy 1.9.3, on 2023-09-20 12:10.
```

Example 36 (python):
```python
sc.tl.diffmap(adata)
sc.pl.diffmap(adata, color='fine_grain')
```

Example 37 (python):
```python
sc.pl.diffmap(adata, color='fine_grain', dimensions= [(0, 1), (1, 2), (0, 2)])
sc.pl.diffmap(adata, color='cycling', dimensions= [(0, 1), (1, 2), (0, 2)])
```

Example 38 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 39 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 40 (python):
```python
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

color_categories=pd.Categorical(adata.obs['fine_grain'])
colors=color_categories.codes
X_diffmap=adata.obsm['X_diffmap']
fig=plt.figure(figsize=(8,6))
ax=fig.add_subplot(111,projection='3d')
ax.scatter(X_diffmap[:,1],X_diffmap[:,2],X_diffmap[:,3], c=colors)
ax.view_init(elev=20, azim=50)

color_categories=pd.Categorical(adata.obs['cycling'])
colors=color_categories.codes
X_diffmap=adata.obsm['X_diffmap']
fig=plt.figure(figsize=(8,6))
ax=fig.add_subplot(111,projection='3d')
ax.scatter(X_diffmap[:,1],X_diffmap[:,2],X_diffmap[:,3], c=colors)
ax.view_init(elev=20, azim=50)
```

Example 41 (python):
```python
adata=sc.read('./CoronaryEndothelialCellsscFates.h5ad')
print(adata.shape)
```

Example 42 (unknown):
```unknown
(8375, 1332)
```

Example 43 (unknown):
```unknown
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
```

Example 44 (python):
```python
sc.pl.diffmap(adata, color='fine_grain')
sc.pl.diffmap(adata, color='cycling')
```

Example 45 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 46 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 47 (python):
```python
#adata.obsm['X_umap']=adata.obsm['X_diffmap'] #dont run this
```

Example 48 (python):
```python
projections = pd.DataFrame(adata.obsm["X_scVI"],index=adata.obs_names)
projections
# fate probability mapping of the cells
dm_res = palantir.utils.run_diffusion_maps(projections)
ms_data = palantir.utils.determine_multiscale_space(dm_res,n_eigs=4)
# Generate embedding from the multiscale diffusion space
adata.obsm["X_palantir"]=ms_data.values
sc.pp.neighbors(adata,n_neighbors=30,use_rep="X_palantir")
sc.pl.embedding(adata, basis='X_palantir',color=['fine_grain'], components='all',ncols=3,wspace=0.6,size=10)

# draw ForceAtlas2 embedding using UMAP dim1 and dim2 as initial position
# make obsm with UMAP1 and 2
adata.obsm['X_umap12'] = adata.obsm['X_umap'][:,[0,1]]
sc.tl.draw_graph(adata,init_pos='X_umap12')
# Plot
sc.set_figure_params(dpi=120)
sc.pl.draw_graph(adata,color="fine_grain",color_map="RdBu_r")
```

Example 49 (unknown):
```unknown
Determing nearest neighbor graph...
computing neighbors
```

Example 50 (python):
```python
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 51 (unknown):
```unknown
finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:10)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
```

Example 52 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 53 (python):
```python
drawing single-cell graph using layout 'fa'
WARNING: Package 'fa2' is not installed, falling back to layout 'fr'.To use the faster and better ForceAtlas2 layout, install package 'fa2' (`pip install fa2`).
    finished: added
    'X_draw_graph_fr', graph_drawing coordinates (adata.obsm) (0:00:11)
```

Example 54 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 55 (python):
```python
scf.tl.curve(adata,Nodes=40,use_rep="X_palantir",ndims_rep=2,epg_lambda=0.0001,epg_mu=0.1)
scf.pl.graph(adata,basis="palantir")
scf.tl.convert_to_soft(adata,0.1,500)
scf.pl.graph(adata,basis="palantir")

scf.tl.root(adata,"NR2F2")
scf.tl.pseudotime(adata,n_jobs=20,n_map=100,seed=42)
scf.pl.trajectory(adata,basis="palantir",arrows=True,arrow_offset=3)
scf.pl.trajectory(adata,basis="palantir",arrows=False,arrow_offset=3)
adata=adata.raw.to_adata()
```

Example 56 (python):
```python
inferring a principal curve --> parameters used 
    40 principal points, mu = 0.1, lambda = 0.0001
    finished (0:00:01) --> added 
    .uns['epg'] dictionnary containing inferred elastic curve generated from elpigraph.
    .obsm['X_R'] hard assignment of cells to principal points.
    .uns['graph']['B'] adjacency matrix of the principal points.
    .uns['graph']['F'], coordinates of principal points in representation space.
```

Example 57 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  cax = scatter(
```

Example 58 (unknown):
```unknown
Converting R into soft assignment matrix
    finished (0:00:00) --> updated 
    .obsm['X_R'] converted soft assignment of cells to principal points.
    .uns['graph']['F'] coordinates of principal points in representation space.
```

Example 59 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  cax = scatter(
```

Example 60 (python):
```python
automatic root selection using NR2F2 values
node 0 selected as a root --> added
    .uns['graph']['root'] selected root.
    .uns['graph']['pp_info'] for each PP, its distance vs root and segment assignment.
    .uns['graph']['pp_seg'] segments network information.
projecting cells onto the principal graph
    mappings: 100%|███████████████████████████| 100/100 [00:29<00:00,  3.35it/s]
    finished (0:00:32) --> added
    .obs['edge'] assigned edge.
    .obs['t'] pseudotime value.
    .obs['seg'] segment of the tree assigned.
    .obs['milestones'] milestone assigned.
    .uns['pseudotime_list'] list of cell projection from all mappings.
```

Example 61 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  cax = scatter(
```

Example 62 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  cax = scatter(
```

Example 63 (python):
```python
scf.tl.linearity_deviation(adata,start_milestone="0",end_milestone="2",n_jobs=20,plot=True,basis="palantir")
scf.pl.linearity_deviation(adata,start_milestone="0",end_milestone="2")
sc.pl.umap(adata,color=["H19","IGFBP3","PDGFB"])
```

Example 64 (python):
```python
Estimation of deviation from linearity
    cells on the bridge: 100%|█████████████| 5175/5175 [00:10<00:00, 476.72it/s]
```

Example 65 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scFates/tools/linearity_deviation.py:144: RuntimeWarning: invalid value encountered in divide
  return rs.mean(axis=1) / X_all.std(axis=0)
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 66 (python):
```python
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scFates/tools/linearity_deviation.py:164: RuntimeWarning: Mean of empty slice
  adata.var[name + "_rss"] = np.nanmean(np.vstack(rss), axis=0)
```

Example 67 (unknown):
```unknown
finished (0:00:16) --> added 
    .var['0->2_rss'], pearson residuals of the linear fit.
    .obs['0->2_lindev_sel'], cell selections used for the test.
```

Example 68 (python):
```python
scf.tl.test_association(adata,n_jobs=20)
scf.tl.test_association(adata,reapply_filters=True,A_cut=.5)
scf.pl.test_association(adata)
scf.tl.fit(adata,n_jobs=20)
```

Example 69 (python):
```python
test features for association with the trajectory
    single mapping : 100%|████████████████| 36601/36601 [15:03<00:00, 40.51it/s]
    found 233 significant features (0:15:03) --> added
    .var['p_val'] values from statistical test.
    .var['fdr'] corrected values from multiple testing.
    .var['st'] proportion of mapping in which feature is significant.
    .var['A'] amplitue of change of tested feature.
    .var['signi'] feature is significantly changing along pseudotime.
    .uns['stat_assoc_list'] list of fitted features on the graph for all mappings.
reapplied filters, 1024 significant features
fit features associated with the trajectory
    single mapping : 100%|██████████████████| 1024/1024 [00:32<00:00, 31.48it/s]
    finished (adata subsetted to keep only fitted features!) (0:00:33) --> added
    .layers['fitted'], fitted features on the trajectory for all mappings.
    .raw, unfiltered data.
```

Example 70 (python):
```python
scf.pl.single_trend(adata,"NR2F2",basis="palantir",color_exp="k")
scf.pl.single_trend(adata,"RGCC",basis="palantir",color_exp="k")
scf.pl.single_trend(adata,"HEY2",basis="palantir",color_exp="k")
scf.pl.single_trend(adata,"TOP2A",basis="palantir",color_exp="k")
scf.pl.single_trend(adata,"MKI67",basis="palantir",color_exp="k")
```

Example 71 (python):
```python
GOI=['UBE2C','NUSAP1','CENPF','TOP2A','MKI67','NR2F2','RGCC','HEY2']
scf.pl.trends(adata,features=GOI,basis="palantir")
```

Example 72 (python):
```python
adata.write('./CoronaryEndotheliumscFatesProcessedForCellCycling.h5ad')
```

Example 73 (python):
```python
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/methods.py:292: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  write_elem(f, k, np.array(elem), dataset_kwargs=dataset_kwargs)
```

Example 74 (python):
```python
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/utils.py:214, in report_write_key_on_error.<locals>.func_wrapper(elem, key, val, *args, **kwargs)
    213 try:
--> 214     return func(elem, key, val, *args, **kwargs)
    215 except Exception as e:

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/registry.py:171, in write_elem(f, k, elem, modifiers, *args, **kwargs)
    167 if (
    168     hasattr(elem, "dtype")
    169     and (dest_type, (t, elem.dtype.kind), modifiers) in _REGISTRY.write
    170 ):
--> 171     _REGISTRY.get_writer(dest_type, (t, elem.dtype.kind), modifiers)(
    172         f, k, elem, *args, **kwargs
    173     )
    174 else:

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/registry.py:24, in write_spec.<locals>.decorator.<locals>.wrapper(g, k, *args, **kwargs)
     22 @wraps(func)
     23 def wrapper(g, k, *args, **kwargs):
---> 24     result = func(g, k, *args, **kwargs)
     25     g[k].attrs.setdefault("encoding-type", spec.encoding_type)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/methods.py:346, in write_vlen_string_array(f, k, elem, dataset_kwargs)
    345 str_dtype = h5py.special_dtype(vlen=str)
--> 346 f.create_dataset(k, data=elem.astype(str_dtype), dtype=str_dtype, **dataset_kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/h5py/_hl/group.py:183, in Group.create_dataset(self, name, shape, dtype, data, **kwds)
    181         group = self.require_group(parent_path)
--> 183 dsid = dataset.make_new_dset(group, shape, dtype, data, name, **kwds)
    184 dset = dataset.Dataset(dsid)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/h5py/_hl/dataset.py:168, in make_new_dset(parent, shape, dtype, data, name, chunks, compression, shuffle, fletcher32, maxshape, compression_opts, fillvalue, scaleoffset, track_times, external, track_order, dcpl, dapl, efile_prefix, virtual_prefix, allow_unknown_filter, rdcc_nslots, rdcc_nbytes, rdcc_w0)
    167 if (data is not None) and (not isinstance(data, Empty)):
--> 168     dset_id.write(h5s.ALL, h5s.ALL, data)
    170 return dset_id

File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()

File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()

File h5py/h5d.pyx:280, in h5py.h5d.DatasetID.write()

File h5py/_proxy.pyx:145, in h5py._proxy.dset_rw()

File h5py/_conv.pyx:444, in h5py._conv.str2vlen()

File h5py/_conv.pyx:95, in h5py._conv.generic_converter()

File h5py/_conv.pyx:249, in h5py._conv.conv_str2vlen()

TypeError: Can't implicitly convert non-string objects to strings

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
Cell In[51], line 1
----> 1 adata.write('./CoronaryEndotheliumscFatesProcessedForCellCycling.h5ad')

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_core/anndata.py:1918, in AnnData.write_h5ad(self, filename, compression, compression_opts, force_dense, as_dense)
   1915 if filename is None:
   1916     filename = self.filename
-> 1918 _write_h5ad(
   1919     Path(filename),
   1920     self,
   1921     compression=compression,
   1922     compression_opts=compression_opts,
   1923     force_dense=force_dense,
   1924     as_dense=as_dense,
   1925 )
   1927 if self.isbacked:
   1928     self.file.filename = filename

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/h5ad.py:105, in write_h5ad(filepath, adata, force_dense, as_dense, dataset_kwargs, **kwargs)
    103 write_elem(f, "varp", dict(adata.varp), dataset_kwargs=dataset_kwargs)
    104 write_elem(f, "layers", dict(adata.layers), dataset_kwargs=dataset_kwargs)
--> 105 write_elem(f, "uns", dict(adata.uns), dataset_kwargs=dataset_kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/utils.py:214, in report_write_key_on_error.<locals>.func_wrapper(elem, key, val, *args, **kwargs)
    211 @wraps(func)
    212 def func_wrapper(elem, key, val, *args, **kwargs):
    213     try:
--> 214         return func(elem, key, val, *args, **kwargs)
    215     except Exception as e:
    216         if "Above error raised while writing key" in format(e):

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/registry.py:175, in write_elem(f, k, elem, modifiers, *args, **kwargs)
    171     _REGISTRY.get_writer(dest_type, (t, elem.dtype.kind), modifiers)(
    172         f, k, elem, *args, **kwargs
    173     )
    174 else:
--> 175     _REGISTRY.get_writer(dest_type, t, modifiers)(f, k, elem, *args, **kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/registry.py:24, in write_spec.<locals>.decorator.<locals>.wrapper(g, k, *args, **kwargs)
     22 @wraps(func)
     23 def wrapper(g, k, *args, **kwargs):
---> 24     result = func(g, k, *args, **kwargs)
     25     g[k].attrs.setdefault("encoding-type", spec.encoding_type)
     26     g[k].attrs.setdefault("encoding-version", spec.encoding_version)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/methods.py:281, in write_mapping(f, k, v, dataset_kwargs)
    279 g = f.create_group(k)
    280 for sub_k, sub_v in v.items():
--> 281     write_elem(g, sub_k, sub_v, dataset_kwargs=dataset_kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/utils.py:214, in report_write_key_on_error.<locals>.func_wrapper(elem, key, val, *args, **kwargs)
    211 @wraps(func)
    212 def func_wrapper(elem, key, val, *args, **kwargs):
    213     try:
--> 214         return func(elem, key, val, *args, **kwargs)
    215     except Exception as e:
    216         if "Above error raised while writing key" in format(e):

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/registry.py:175, in write_elem(f, k, elem, modifiers, *args, **kwargs)
    171     _REGISTRY.get_writer(dest_type, (t, elem.dtype.kind), modifiers)(
    172         f, k, elem, *args, **kwargs
    173     )
    174 else:
--> 175     _REGISTRY.get_writer(dest_type, t, modifiers)(f, k, elem, *args, **kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/registry.py:24, in write_spec.<locals>.decorator.<locals>.wrapper(g, k, *args, **kwargs)
     22 @wraps(func)
     23 def wrapper(g, k, *args, **kwargs):
---> 24     result = func(g, k, *args, **kwargs)
     25     g[k].attrs.setdefault("encoding-type", spec.encoding_type)
     26     g[k].attrs.setdefault("encoding-version", spec.encoding_version)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/methods.py:281, in write_mapping(f, k, v, dataset_kwargs)
    279 g = f.create_group(k)
    280 for sub_k, sub_v in v.items():
--> 281     write_elem(g, sub_k, sub_v, dataset_kwargs=dataset_kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/utils.py:214, in report_write_key_on_error.<locals>.func_wrapper(elem, key, val, *args, **kwargs)
    211 @wraps(func)
    212 def func_wrapper(elem, key, val, *args, **kwargs):
    213     try:
--> 214         return func(elem, key, val, *args, **kwargs)
    215     except Exception as e:
    216         if "Above error raised while writing key" in format(e):

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/registry.py:175, in write_elem(f, k, elem, modifiers, *args, **kwargs)
    171     _REGISTRY.get_writer(dest_type, (t, elem.dtype.kind), modifiers)(
    172         f, k, elem, *args, **kwargs
    173     )
    174 else:
--> 175     _REGISTRY.get_writer(dest_type, t, modifiers)(f, k, elem, *args, **kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/registry.py:24, in write_spec.<locals>.decorator.<locals>.wrapper(g, k, *args, **kwargs)
     22 @wraps(func)
     23 def wrapper(g, k, *args, **kwargs):
---> 24     result = func(g, k, *args, **kwargs)
     25     g[k].attrs.setdefault("encoding-type", spec.encoding_type)
     26     g[k].attrs.setdefault("encoding-version", spec.encoding_version)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/specs/methods.py:292, in write_list(f, k, elem, dataset_kwargs)
    289 @_REGISTRY.register_write(H5Group, list, IOSpec("array", "0.2.0"))
    290 @_REGISTRY.register_write(ZarrGroup, list, IOSpec("array", "0.2.0"))
    291 def write_list(f, k, elem, dataset_kwargs=MappingProxyType({})):
--> 292     write_elem(f, k, np.array(elem), dataset_kwargs=dataset_kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/_io/utils.py:220, in report_write_key_on_error.<locals>.func_wrapper(elem, key, val, *args, **kwargs)
    218 else:
    219     parent = _get_parent(elem)
--> 220     raise type(e)(
    221         f"{e}\n\n"
    222         f"Above error raised while writing key {key!r} of {type(elem)} "
    223         f"to {parent}"
    224     ) from e

TypeError: Can't implicitly convert non-string objects to strings

Above error raised while writing key 'Edges' of <class 'h5py._hl.group.Group'> to /
```

Example 75 (python):
```python
bdata=adata.copy()
```

Example 76 (python):
```python
scf.tl.cluster(adata,n_neighbors=20,metric="correlation")
adata.var.cluters.unique()
```

Example 77 (python):
```python
Clustering features using fitted layer
computing PCA
    with n_comps=50
    finished (0:00:01)
computing neighbors
    using 'X_pca' with n_pcs = 50
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
running Leiden clustering
    finished: found 12 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
    finished (0:00:03) --> added 
    .var['cluters'] identified modules.
```

Example 78 (unknown):
```unknown
['1', '3', '7', '5', '0', ..., '6', '4', '9', '11', '10']
Length: 12
Categories (12, object): ['0', '1', '2', '3', ..., '8', '9', '10', '11']
```

Example 79 (python):
```python
for c in adata.var["cluters"].unique():
    scf.pl.trends(adata,features=adata.var_names[adata.var.cluters==c],basis="palantir")
```

Example 80 (python):
```python
GOI=['NR2F2','UBE2C','NUSAP1','ASPM','CENPF','TOP2A','MKI67','RGCC','HEY2']
scf.pl.trends(adata,features=GOI,basis="palantir")
```

Example 81 (python):
```python
GOI=['UBE2C','NUSAP1','ASPM','CENPF','TOP2A','MKI67']
scf.pl.trends(adata,features=GOI,basis="palantir")
```

Example 82 (python):
```python
GOI=['NR2F2']
scf.pl.trends(adata,features=GOI,basis="palantir")
```

Example 83 (python):
```python
sc.pl.draw_graph(adata,color="fine_grain",color_map="RdBu_r")
```

Example 84 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 85 (python):
```python
sc.pl.embedding(adata, basis='X_palantir',color=['fine_grain'],ncols=3,wspace=0.6,size=10)
```

Example 86 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_MuralCells.html

**Contents:**
- Variables¶
- Read in data¶
- Markers¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 1 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
# import session_info
# session_info.show()
```

Example 3 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 4 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 5 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'MuralCells'
```

Example 6 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 7 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 8 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 10986 × 4771
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 10 (python):
```python
adata.X.data[:5]
```

Example 11 (unknown):
```unknown
array([2.999922, 2.999922, 2.999922, 2.999922, 2.999922], dtype=float32)
```

Example 12 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 13 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 14 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 15 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 16 (unknown):
```unknown
CPU times: user 7.11 s, sys: 112 ms, total: 7.23 s
Wall time: 7.25 s
```

Example 17 (python):
```python
# read in markers identified using single-nucleus data
markers_df = pd.read_csv(f'/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_{celltype}_finegrain_markers.csv')

mask1 = markers_df['group_mean']>1
mask2 = markers_df['logfoldchanges']>1
markers_df = markers_df[mask1&mask2]

markers_df
```

Example 18 (python):
```python
markers = {}
n_top = 15
for c in set(markers_df['group']):
    markers_df_sub = markers_df[markers_df['group']==c]
    markers_df_sub.sort_values('logfoldchanges',ascending=False)
    markers[c]=list(markers_df_sub[:n_top]['names'])

# manually add genes
markers['Cycling'] = ['MKI67','TOP2A'] 

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in list(adata.var_names))&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in list(adata.var_names)]
len(genes)
```

Example 19 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",color=genes, size=10,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 20 (unknown):
```unknown
resolution_sel = 0.4
```

Example 21 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              markers_others, 
              groupby=f'leiden_{str(resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 22 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 23 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 24 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CoronaryPericytes, DuctusArteriosusSmoothMuscleCells, CoronarySmoothMuscleCells, etc.
```

Example 25 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 26 (unknown):
```unknown
[2.999922 2.999922 2.999922 2.999922 2.999922]
```

Example 27 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 28 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 29 (unknown):
```unknown
'MuralCells'
```

Example 30 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'MuralCells',
    '1':'unassigned',
    '2':'MuralCells',
    '3':'MuralCells',
    '4':'MuralCells',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 31 (python):
```python
/tmp/ipykernel_158712/842149592.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 32 (unknown):
```unknown
tmp_annotation
MuralCells    7486
unassigned    3500
Name: count, dtype: int64
```

Example 33 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 34 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['MuralCells'])]
```

Example 35 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 36 (unknown):
```unknown
AnnData object with n_obs × n_vars = 7486 × 4771
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.4', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 37 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 38 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 7486 × 4298
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.4', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 39 (python):
```python
'''
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
'''
```

Example 40 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 41 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 42 (unknown):
```unknown
number of hvgs: 821
```

Example 43 (python):
```python
2025-06-12 16:43:00,616 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-12 16:43:02,801 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-12 16:43:02,917 - harmonypy - INFO - Iteration 1 of 10
2025-06-12 16:43:03,945 - harmonypy - INFO - Iteration 2 of 10
2025-06-12 16:43:04,940 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 44 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 45 (unknown):
```unknown
CPU times: user 10.7 s, sys: 129 ms, total: 10.8 s
Wall time: 10.9 s
```

Example 46 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",size=10,
                color=genes,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 47 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=["conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 48 (python):
```python
# umap per celltype to highlight
group_col = 'celltypist_midmod2fine'
groups_to_plot = list(set(adata_sub.obs[group_col]))

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,8))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                    color=[group_col], groups=grp, 
               size=10, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 49 (unknown):
```unknown
sub_resolution_sel = 0.6
```

Example 50 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              markers_others, 
              groupby=f'leiden_{str(sub_resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 51 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 52 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 53 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CoronaryPericytes, DuctusArteriosusSmoothMuscleCells, CoronarySmoothMuscleCells, etc.
```

Example 54 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 55 (unknown):
```unknown
[2.4700055 3.11994   3.11994   3.7907598 2.4700055]
```

Example 56 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 57 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'GreatVesselSmoothMuscleCells',
    '1':'CoronaryPericytes',
    '2':'GreatVesselSmoothMuscleCellsCycling',
    '3':'CoronarySmoothMuscleCells',
    '4':'DuctusArteriosusSmoothMuscleCells',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 58 (python):
```python
/tmp/ipykernel_158712/3157763043.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 59 (unknown):
```unknown
fine_grain_manual
GreatVesselSmoothMuscleCells           2358
CoronaryPericytes                      1990
GreatVesselSmoothMuscleCellsCycling    1312
CoronarySmoothMuscleCells              1026
DuctusArteriosusSmoothMuscleCells       800
Name: count, dtype: int64
```

Example 60 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 61 (python):
```python
sc.tl.dendrogram(adata_sub,groupby='fine_grain_manual')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 62 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: GreatVesselSmoothMuscleCells, CoronaryPericytes, GreatVesselSmoothMuscleCellsCycling, etc.
var_group_labels: CoronaryPericytes, DuctusArteriosusSmoothMuscleCells, CoronarySmoothMuscleCells, etc.
```

Example 63 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 64 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 65 (python):
```python
sc.tl.dendrogram(adata,groupby='fine_grain_manual')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 66 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: CoronaryPericytes, CoronarySmoothMuscleCells, DuctusArteriosusSmoothMuscleCells, etc.
var_group_labels: CoronaryPericytes, DuctusArteriosusSmoothMuscleCells, CoronarySmoothMuscleCells, etc.
```

Example 67 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=60,vmax='p100')
```

Example 68 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 69 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 70 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 71 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 72 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 73 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 74 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 75 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 76 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 77 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 78 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 79 (python):
```python
/tmp/ipykernel_158712/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 80 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 81 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_MuralCells_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Mesenchymal/MyocardialFibroblasts.html

**Contents:**
- Subcluster¶
- Investigate if there are adventitial specific genes¶

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-05-16 17:19.
```

Example 5 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(297473, 36601)
```

Example 7 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 8 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 9 (python):
```python
#Expression: "YlGn" (e.g. DE plots)
#Divergent expression: "PRGn" (e.g. log2FC)
#Age: "afmhot_r"
#Others: "viridis" (e.g. UMAP expression)

#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodePacemakerCells':'#854834',
    'AtrioventricularNodePacemakerCells':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 10 (python):
```python
set(adata.obs.fine_grain)
```

Example 11 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 12 (python):
```python
set(adata.obs.mid_grain)
```

Example 13 (unknown):
```unknown
{'AtrialCardiomyocytes',
 'BloodVesselEndothelialCells',
 'CardiacConductionSystem',
 'EndocardialCells',
 'EpicardialCells',
 'Fibroblasts',
 'Glia',
 'LymphaticEndothelialCells',
 'LymphoidCells',
 'MuralCells',
 'MyeloidCells',
 'Neurons',
 'PericardialCells',
 'VentricularCardiomyocytes'}
```

Example 14 (python):
```python
set(adata.obs.coarse_grain)
```

Example 15 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Leukocytes',
 'Mesenchymal',
 'Neural'}
```

Example 16 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
adata = adata[adata.obs['fine_grain'].isin(['Myofibroblasts','CoronaryVesselAdventitialFibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts'])].copy()
#adata = adata[adata.obs['mid_grain'].isin(['PericardialCells'])].copy()
#adata=adata[adata.obs.mid_grain=='MuralCells',:].copy()
```

Example 17 (unknown):
```unknown
AnnData object with n_obs × n_vars = 32645 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 18 (python):
```python
set(adata.obs.fine_grain)
```

Example 19 (unknown):
```unknown
{'CoronaryVesselAdventitialFibroblasts',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'SubEpicardialFibroblasts'}
```

Example 20 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 21 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:10)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1790
```

Example 22 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['FEN1', 'MCM2', 'MCM4', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    370 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['ANP32E', 'RANGAP1', 'LBR', 'CTCF', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    735 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 23 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 24 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [02:21<00:00,  2.83s/it, loss=766, v_num=1]
```

Example 25 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    489 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBE1', 'HBZ', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    198 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:04)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:09)
```

Example 26 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 27 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 28 (python):
```python
sc.pl.umap(adata, color='region')
```

Example 29 (python):
```python
sc.pl.umap(adata, color='fine_grain')
```

Example 30 (python):
```python
sc.tl.leiden(adata, resolution=0.2, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 31 (python):
```python
running Leiden clustering
    finished: found 4 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:04)
```

Example 32 (python):
```python
set(adata.obs.fine_grain)
```

Example 33 (unknown):
```unknown
{'CoronaryVesselAdventitialFibroblasts',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'SubEpicardialFibroblasts'}
```

Example 34 (python):
```python
FineGrainPalette2={
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'cycling':'#005aa0',
}

adata.obs['fine_grain2']= 'na'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.fine_grain[x]=='CoronaryVesselAdventitialFibroblasts']]='CoronaryVesselAdventitialFibroblasts'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.fine_grain[x]=='MyocardialInterstitialFibroblasts']]='MyocardialInterstitialFibroblasts'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.fine_grain[x]=='SubEpicardialFibroblasts']]='SubEpicardialFibroblasts'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.fine_grain[x]=='Myofibroblasts']]='Myofibroblasts'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.leiden[x] in ['3']]]='cycling'
sc.pl.umap(adata, color='fine_grain2',palette=FineGrainPalette2)
```

Example 35 (unknown):
```unknown
... storing 'fine_grain2' as categorical
```

Example 36 (python):
```python
sc.pl.umap(adata, color='region',groups=['left ventricle','right ventricle','right ventricle and papillaries'])
sc.pl.umap(adata, color='region',groups=['base','atrial septum','atria'])
sc.pl.umap(adata, color='region',groups=['node','atria'])
```

Example 37 (python):
```python
ClusterOfInterest='Myofibroblasts'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 38 (python):
```python
FineGrainCategoriesOrder=['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts']
Genes=['DCN','PDGFRA','TCF21','MOXD1','FNDC1','FBLN5','DES','CEMIP','SCN7A','COL15A1','ROBO2','ROBO2','CD34','COL25A1','MYRIP','NRG1','SLIT3','MIR100HG','FLRT2','BNC2','CASC15','TSHZ2','PRRX1','SFRP1','BRINP3','EPHA3','IGFBP7','SEMA5A','APOE','ITGA1','HES4','NOTCH3','PLA2G5','APOE','MCAM']
sc.pl.dotplot(adata , var_group_positions=[(3,7),(8,15),(16,25),(26,34)], var_group_labels=['coronary adventitial','myocardial fibroblasts 1','myocardial fibroblasts 2','myofibroblasts'], var_group_rotation=90,groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn')
```

Example 39 (python):
```python
Genes=['DCN','PDGFRA','TCF21','MOXD1','FNDC1','FBLN5','DES','CEMIP','SLIT3','MIR100HG','FLRT2','BNC2','CASC15','TSHZ2','PRRX1','SFRP1','BRINP3','EPHA3','SCN7A','COL15A1','ROBO2','CD34','COL25A1','MYRIP','NRG1','IGFBP7','SEMA5A','APOE','ITGA1','HES4','NOTCH3','PLA2G5','MCAM']
print(set([x for x in Genes if Genes.count(x) > 1]))
FineGrainCategoriesOrder=['CoronaryVesselAdventitialFibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts','Myofibroblasts']
sc.pl.dotplot(adata, Genes ,var_group_positions=[(0,7),(8,17),(18,24),(25,33)], var_group_labels=['coronary adventitial','subepicardial','myocardial interstitial','myofibroblasts'], var_group_rotation=0,groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn')
```

Example 40 (python):
```python
bdata=adata[adata.obs.fine_grain2=='Myofibroblasts',:].copy()
sc.tl.umap(bdata,min_dist=0.1)
```

Example 41 (python):
```python
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:02)
```

Example 42 (python):
```python
sc.pl.umap(bdata, color=['MYH11','PLA2G5','ACTA2','PLA2G5','PDGFRA','PDGFRB','HES4','TAGLN'])
```

Example 43 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)

adata = adata[adata.obs['fine_grain'].isin(['Myofibroblasts','CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','GreatVesselAdventitialFibroblasts'])].copy()


# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 44 (python):
```python
(297473, 36601)
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:14)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
2154
```

Example 45 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    373 total control genes are used. (0:00:01)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['CKS1B', 'ANP32E', 'RANGAP1', 'LBR', 'CTCF', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    650 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 46 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 47 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [08:03<00:00,  9.67s/it, loss=883, v_num=1]
```

Example 48 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    290 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBZ', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    248 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:07)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:28)
```

Example 49 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 50 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 51 (python):
```python
adata.obs['adventitial']= 'na'
adata.obs['adventitial'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['Myofibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2']]]='no'
adata.obs['adventitial'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['CoronaryVesselAdventitialFibroblasts','GreatVesselAdventitialFibroblasts']]]='yes'
sc.pl.umap(adata, color='adventitial')
```

Example 52 (unknown):
```unknown
... storing 'adventitial' as categorical
```

Example 53 (python):
```python
sc.tl.rank_genes_groups(adata, 'adventitial', method='t-test', key_added = "t-test")

ClusterOfInterest='yes'
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')

ClusterOfInterest='no'
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
```

Example 54 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:03)
```

Example 55 (python):
```python
FineGrainCategoriesOrder=['GreatVesselAdventitialFibroblasts','CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts']
sc.pl.dotplot(adata, ['SLIT3','SERPINF1','FBLN5','KAZN','GAS1','ZFHX4','CRABP2','SOD3'] ,categories_order=FineGrainCategoriesOrder,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 56 (python):
```python
sc.pl.dotplot(adata, ['DCN','PDGFRA','TCF21','MOXD1','FNDC1','FBLN5','DES','CEMIP','SCN7A','COL15A1','ROBO2','ROBO2','CD34','COL25A1','MYRIP','NRG1','SLIT3','MIR100HG','FLRT2','BNC2','CASC15','TSHZ2','PRRX1','SFRP1','BRINP3','EPHA3','IGFBP7','SEMA5A','APOE','ITGA1','HES4','NOTCH3','PLA2G5','APOE','MCAM'] ,categories_order=FineGrainCategoriesOrder,groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Supplementary_materials/Epigenetic_stability/no2a_RNA-nhoods_scVI-embedding.html

**Contents:**
- Import module¶
- Parameters¶
- Differential acundance test (Milo)¶
- Define nhoods: Young, Old, Non-significant¶

**Examples:**

Example 1 (python):
```python
import numpy as np
import pandas as pd 
import scanpy as sc
import matplotlib.pyplot as plt
import seaborn as sns
# import sctk
```

Example 2 (python):
```python
# Configure rpy2 to Use the Correct R Installation:
import os
os.environ['R_HOME'] = '/nfs/team205/kk18/miniconda3/envs/vitro/lib/R'
# check
from rpy2.rinterface_lib import openrlib
print(openrlib.R_HOME)
```

Example 3 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/R
```

Example 4 (python):
```python
import milopy.core as milo
import milopy.plot as milopl
import milopy.utils
```

Example 5 (python):
```python
import session_info
session_info.show()
```

Example 6 (python):
```python
-----
matplotlib          3.7.2
milopy              0.1.1
numpy               1.24.4
pandas              1.5.3
rpy2                3.5.14
scanpy              1.9.3
seaborn             0.12.2
session_info        1.0.0
-----
```

Example 7 (python):
```python
PIL                         10.0.0
anndata                     0.9.2
anyio                       NA
arrow                       1.2.3
asttokens                   NA
attr                        23.1.0
attrs                       23.1.0
babel                       2.12.1
backcall                    0.2.0
backports                   NA
brotli                      1.0.9
certifi                     2023.11.17
cffi                        1.15.1
charset_normalizer          3.2.0
colorama                    0.4.6
comm                        0.1.4
cycler                      0.10.0
cython_runtime              NA
dateutil                    2.8.2
debugpy                     1.6.8
decorator                   5.1.1
defusedxml                  0.7.1
executing                   1.2.0
fastjsonschema              NA
fqdn                        NA
h5py                        3.9.0
idna                        3.4
igraph                      0.10.6
importlib_metadata          NA
importlib_resources         NA
ipykernel                   6.25.1
isoduration                 NA
jedi                        0.19.0
jinja2                      3.1.2
joblib                      1.3.2
json5                       NA
jsonpointer                 2.0
jsonschema                  4.19.0
jsonschema_specifications   NA
jupyter_events              0.7.0
jupyter_server              2.7.1
jupyterlab_server           2.24.0
kiwisolver                  1.4.5
leidenalg                   0.10.1
llvmlite                    0.40.1
markupsafe                  2.1.3
mpl_toolkits                NA
natsort                     8.4.0
nbformat                    5.9.2
numba                       0.57.1
overrides                   NA
packaging                   23.1
parso                       0.8.3
patsy                       0.5.3
pexpect                     4.8.0
pickleshare                 0.7.5
pkg_resources               NA
plotly                      5.16.1
prometheus_client           NA
prompt_toolkit              3.0.39
psutil                      5.9.5
ptyprocess                  0.7.0
pure_eval                   0.2.2
pydev_ipython               NA
pydevconsole                NA
pydevd                      2.9.5
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pygments                    2.16.1
pyparsing                   3.0.9
pythonjsonlogger            NA
pytz                        2023.3
referencing                 NA
requests                    2.31.0
rfc3339_validator           0.1.4
rfc3986_validator           0.1.1
rpds                        NA
ruamel                      NA
scipy                       1.10.1
send2trash                  NA
six                         1.16.0
sklearn                     1.3.0
sniffio                     1.3.0
socks                       1.7.1
sphinxcontrib               NA
stack_data                  0.6.2
statsmodels                 0.14.0
texttable                   1.6.7
threadpoolctl               3.2.0
tornado                     6.3.3
traitlets                   5.9.0
typing_extensions           NA
tzlocal                     NA
uri_template                NA
urllib3                     2.0.4
wcwidth                     0.2.6
webcolors                   1.13
websocket                   1.6.2
yaml                        6.0.1
zipp                        NA
zmq                         25.1.1
zstandard                   0.19.0
```

Example 8 (unknown):
```unknown
-----
IPython             8.12.0
jupyter_client      8.3.0
jupyter_core        4.12.0
jupyterlab          4.0.5
notebook            7.0.2
-----
Python 3.8.17 (default, Jul  5 2023, 21:04:15) [GCC 11.2.0]
Linux-4.15.0-220-generic-x86_64-with-glibc2.17
-----
Session information updated at 2024-01-30 14:05
```

Example 9 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/nfs/team205/kk18/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 10 (python):
```python
sc.settings.set_figure_params(dpi=120)
```

Example 11 (unknown):
```unknown
outdir = '/nfs/team205/heart/anndata_objects/Foetal/multiome_ATAC/ArchR/project_output/Milo_nhoods_gex/scVI_mid_grain_mod'
```

Example 12 (unknown):
```unknown
!ls /nfs/team205/heart/anndata_objects/Foetal/scVI/subsets
```

Example 13 (unknown):
```unknown
Foetal_multiome_AtrialCardiomyocytes_plusCCS_one-layer_added-cov-region.h5ad
Foetal_multiome_AtrialCardiomyocytes_plusCCS_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_AtrialCardiomyocytes_plusCCS_one-layer.h5ad
Foetal_multiome_AtrialCardiomyocytes_plusCCS_three-layer.h5ad
Foetal_multiome_AtrialCardiomyocytes_plusCCS_two-layer.h5ad
Foetal_multiome_BloodVesselEndothelialCells_one-layer_added-cov-region.h5ad
Foetal_multiome_BloodVesselEndothelialCells_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_BloodVesselEndothelialCells_one-layer.h5ad
Foetal_multiome_BloodVesselEndothelialCells_three-layer.h5ad
Foetal_multiome_BloodVesselEndothelialCells_two-layer.h5ad
Foetal_multiome_EndocardialCells_one-layer_added-cov-region.h5ad
Foetal_multiome_EndocardialCells_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_EndocardialCells_one-layer.h5ad
Foetal_multiome_EndocardialCells_three-layer.h5ad
Foetal_multiome_EndocardialCells_two-layer.h5ad
Foetal_multiome_EpicardialCells_one-layer_added-cov-region.h5ad
Foetal_multiome_EpicardialCells_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_EpicardialCells_one-layer.h5ad
Foetal_multiome_EpicardialCells_three-layer.h5ad
Foetal_multiome_EpicardialCells_two-layer.h5ad
Foetal_multiome_Fibroblasts_one-layer_added-cov-region.h5ad
Foetal_multiome_Fibroblasts_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_Fibroblasts_one-layer.h5ad
Foetal_multiome_Fibroblasts_three-layer.h5ad
Foetal_multiome_Fibroblasts_two-layer.h5ad
Foetal_multiome_Glia_one-layer_added-cov-region.h5ad
Foetal_multiome_Glia_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_Glia_one-layer.h5ad
Foetal_multiome_Glia_three-layer.h5ad
Foetal_multiome_Glia_two-layer.h5ad
Foetal_multiome_LymphaticEndothelialCells_one-layer_added-cov-region.h5ad
Foetal_multiome_LymphaticEndothelialCells_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_LymphaticEndothelialCells_one-layer.h5ad
Foetal_multiome_LymphaticEndothelialCells_three-layer.h5ad
Foetal_multiome_LymphaticEndothelialCells_two-layer.h5ad
Foetal_multiome_LymphoidCells_one-layer_added-cov-region.h5ad
Foetal_multiome_LymphoidCells_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_LymphoidCells_one-layer.h5ad
Foetal_multiome_LymphoidCells_three-layer.h5ad
Foetal_multiome_LymphoidCells_two-layer.h5ad
Foetal_multiome_MuralCells_one-layer_added-cov-region.h5ad
Foetal_multiome_MuralCells_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_MuralCells_one-layer.h5ad
Foetal_multiome_MuralCells_three-layer.h5ad
Foetal_multiome_MuralCells_two-layer.h5ad
Foetal_multiome_MyeloidCells_one-layer_added-cov-region.h5ad
Foetal_multiome_MyeloidCells_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_MyeloidCells_one-layer.h5ad
Foetal_multiome_MyeloidCells_three-layer.h5ad
Foetal_multiome_MyeloidCells_two-layer.h5ad
Foetal_multiome_Neurons_one-layer_added-cov-region.h5ad
Foetal_multiome_Neurons_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_Neurons_one-layer.h5ad
Foetal_multiome_Neurons_three-layer.h5ad
Foetal_multiome_Neurons_two-layer.h5ad
Foetal_multiome_PericardialCells_one-layer_added-cov-region.h5ad
Foetal_multiome_PericardialCells_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_PericardialCells_one-layer.h5ad
Foetal_multiome_PericardialCells_three-layer.h5ad
Foetal_multiome_PericardialCells_two-layer.h5ad
Foetal_multiome_VentricularCardiomyocytes_plusCCS_one-layer_added-cov-region.h5ad
Foetal_multiome_VentricularCardiomyocytes_plusCCS_one-layer_added-cov-region_subsampled-n1000.h5ad
Foetal_multiome_VentricularCardiomyocytes_plusCCS_one-layer.h5ad
Foetal_multiome_VentricularCardiomyocytes_plusCCS_three-layer.h5ad
Foetal_multiome_VentricularCardiomyocytes_plusCCS_two-layer.h5ad
```

Example 14 (python):
```python
%%time
n_layer = 'one-layer'

adata_dict = {}
for i,celltype in enumerate(['AtrialCardiomyocytes_plusCCS',
                            'VentricularCardiomyocytes_plusCCS',
                             'BloodVesselEndothelialCells',
                             'EndocardialCells',
                            'LymphaticEndothelialCells',
                             'EpicardialCells',
                             'Fibroblasts',
                             'PericardialCells',
                             'MuralCells',
                             'Neurons',
                            'Glia',
                            'MyeloidCells',
                            'LymphoidCells']
                             ):
    print(f'####### {celltype} #######')
    
    adata_dict[celltype] = sc.read_h5ad(f'/nfs/team205/heart/anndata_objects/Foetal/scVI/subsets/Foetal_multiome_{celltype}_{n_layer}_added-cov-region_subsampled-n1000.h5ad')
    print(adata_dict[celltype].shape)
    
    # compute the k-nearest-neighbor graph that is used in both clustering and umap algorithms
    sc.pp.neighbors(adata_dict[celltype], use_rep="X_scVI", n_neighbors=15, key_added="scvi")
    # compute the umap
    sc.tl.umap(adata_dict[celltype], min_dist=0.2, neighbors_key="scvi")
    # cluster the space (we use a lower resolution to get fewer clusters than the default)
    # sc.tl.leiden(adata_dict[celltype], key_added="cluster_pvi", resolution=1, neighbors_key="peakvi")
    # plot
    sc.pl.umap(adata_dict[celltype], color=['week','donor','fine_grain'], size=20, legend_fontsize=12, wspace=0.3,
              cmap='RdPu')
    
    ## Construct neighbourhoods
    milo.make_nhoods(adata_dict[celltype], neighbors_key="scvi", prop=0.05)
    ## Count cells in neighbourhoods
    ## Milo leverages the variation in cell numbers between replicates for the same experimental condition to test for differential abundance. 
    milo.count_nhoods(adata_dict[celltype], sample_col="donor")
    # differential abundance testing
    adata_dict[celltype].obs["week_continuous"] = [int(x.split('W')[0]) for x in adata_dict[celltype].obs["week"]] #rather than adata.obs["week"].cat.codes
    milo.DA_nhoods(adata_dict[celltype], design="~ week_continuous")
    milopy.utils.build_nhood_graph(adata_dict[celltype],basis='X_umap')
    # plot
    milopl.plot_nhood_graph(adata_dict[celltype], 
                        alpha=0.1, ## SpatialFDR level (1%) 
                        min_size=3, ## Size of smallest dot
                        title = 'DA log-Fold Change\n(FDR < 0.1)'
                       )
    # store logFC
    logfcs = abs(adata_dict[celltype].uns['nhood_adata'].obs['logFC'])
    df = pd.DataFrame({'Celltype':celltype,'logFC':logfcs})
    if i==0:
        logfc_df=df.copy()
    else:
        logfc_df=pd.concat([logfc_df,df])

# save adata dictionary
utils.save_pkl(adata_dict, f'{outdir}/{n_layer}_added-cov-region_subsampled-n1000_post_milo_adata_dictionary.pkl')
```

Example 15 (unknown):
```unknown
####### AtrialCardiomyocytes_plusCCS #######
(4381, 24444)
```

Example 16 (python):
```python
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/umap/distances.py:1063: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  @numba.jit()
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/umap/distances.py:1071: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  @numba.jit()
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/umap/distances.py:1086: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  @numba.jit()
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/umap/umap_.py:660: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  @numba.jit()
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 17 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 18 (unknown):
```unknown
####### VentricularCardiomyocytes_plusCCS #######
(6531, 24426)
```

Example 19 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 20 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 21 (unknown):
```unknown
####### BloodVesselEndothelialCells #######
(3028, 24028)
```

Example 22 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 23 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 24 (unknown):
```unknown
####### EndocardialCells #######
(1410, 21154)
```

Example 25 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 26 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 27 (unknown):
```unknown
####### LymphaticEndothelialCells #######
(1000, 20680)
```

Example 28 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 29 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 30 (unknown):
```unknown
####### EpicardialCells #######
(1340, 23572)
```

Example 31 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 32 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 33 (unknown):
```unknown
####### Fibroblasts #######
(6969, 26468)
```

Example 34 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 35 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 36 (unknown):
```unknown
####### PericardialCells #######
(2187, 22516)
```

Example 37 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 38 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 39 (unknown):
```unknown
####### MuralCells #######
(3103, 23056)
```

Example 40 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 41 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 42 (unknown):
```unknown
####### Neurons #######
(1101, 21561)
```

Example 43 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 44 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 45 (unknown):
```unknown
####### Glia #######
(1759, 21535)
```

Example 46 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 47 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 48 (unknown):
```unknown
####### MyeloidCells #######
(4321, 24290)
```

Example 49 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 50 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 51 (unknown):
```unknown
####### LymphoidCells #######
(7006, 24441)
```

Example 52 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 53 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/anndata/_core/anndata.py:121: ImplicitModificationWarning: Transforming to str index.
  warnings.warn("Transforming to str index.", ImplicitModificationWarning)
```

Example 54 (unknown):
```unknown
CPU times: user 2min 28s, sys: 4.19 s, total: 2min 32s
Wall time: 3min 3s
```

Example 55 (python):
```python
adata_dict.keys()
```

Example 56 (unknown):
```unknown
dict_keys(['AtrialCardiomyocytes_plusCCS', 'VentricularCardiomyocytes_plusCCS', 'BloodVesselEndothelialCells', 'EndocardialCells', 'LymphaticEndothelialCells', 'EpicardialCells', 'Fibroblasts', 'PericardialCells', 'MuralCells', 'Neurons', 'Glia', 'MyeloidCells', 'LymphoidCells'])
```

Example 57 (python):
```python
for celltype in adata_dict.keys():
    print(celltype)
    # get adata
    ad = adata_dict[celltype]
    # define nhoods based on the enrichment
    nhoods_res = ad.uns['nhood_adata'].obs.copy()
    nhoods_res['nhood'] = [f'nhood_{x+1}' for x in range(len(nhoods_res))]
    nhoods_res.set_index('nhood',inplace=True)
    nhoods_res['enrichment'] = 'nonsignificant'
    old_inds = nhoods_res.index[(nhoods_res['logFC']>0)&(nhoods_res['FDR']<0.1)]
    nhoods_res.loc[old_inds,'enrichment'] = 'old'
    young_inds = nhoods_res.index[(nhoods_res['logFC']<0)&(nhoods_res['FDR']<0.1)]
    nhoods_res.loc[young_inds,'enrichment'] = 'young'
    print(f'old nhoods: {len(old_inds)}')
    print(f'young nhoods: {len(young_inds)}')
    # prepare cell-by-nhood dataframe and save
    cell_by_nhood = pd.DataFrame(ad.obsm['nhoods'].todense(), columns=nhoods_res.index, index=ad.obs_names)
    # save cell-by-nhood dataframe
    cell_by_nhood.to_csv(f'{outdir}/{n_layer}_added-cov-region_subsampled-n1000_{celltype}_milo_cell-by-nhood.csv')
    
    ### calculate variance of a nhood-cells in scVI latent space ###
    for nhood in cell_by_nhood.columns:
        # get cells of the nhood
        cells = list(cell_by_nhood.index[cell_by_nhood[nhood]==1])
        nhoods_res.loc[nhood,'cells'] = ','.join(cells)
        # get scVI latent space
        matrix = ad[cells].obsm['X_scVI']
        matrix = np.array(matrix)
        # calculate variance of neighboring cells per axis
        variance_per_axis = np.var(matrix, axis=0)
        # aggregate by taking mean
        variance = np.mean(variance_per_axis)
        # store in nhood result dataframe
        nhoods_res.loc[nhood,'variance_scVI-latent'] = variance
    
    # save nhood result dataframe
    nhoods_res.to_csv(f'{outdir}/{n_layer}_added-cov-region_subsampled-n1000_{celltype}_milo_nhoods_result.csv')
```

Example 58 (unknown):
```unknown
AtrialCardiomyocytes_plusCCS
old nhoods: 88
young nhoods: 14
VentricularCardiomyocytes_plusCCS
old nhoods: 79
young nhoods: 11
BloodVesselEndothelialCells
old nhoods: 33
young nhoods: 2
EndocardialCells
old nhoods: 13
young nhoods: 8
LymphaticEndothelialCells
old nhoods: 19
young nhoods: 0
EpicardialCells
old nhoods: 46
young nhoods: 11
Fibroblasts
old nhoods: 155
young nhoods: 26
PericardialCells
old nhoods: 42
young nhoods: 0
MuralCells
old nhoods: 73
young nhoods: 2
Neurons
old nhoods: 2
young nhoods: 16
Glia
old nhoods: 22
young nhoods: 24
MyeloidCells
old nhoods: 79
young nhoods: 0
LymphoidCells
old nhoods: 247
young nhoods: 0
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Endothelial/EndothelialTipInvestigation.html

**Contents:**
- Older analysis on tip stalk cells¶

**Examples:**

Example 1 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 2 (unknown):
```unknown
Global seed set to 0
```

Example 3 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-06-01 14:25.
```

Example 4 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 5 (unknown):
```unknown
(297473, 36601)
```

Example 6 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 7 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 8 (python):
```python
#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodeCardiomyocytes':'#854834',
    'AtrioventricularNodeCardiomyocytes':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts1':'#8a6800',
    'MyocardialInterstitialFibroblasts2':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCells1':'#c95e00',
    'PericardialCells2':'#01e077',
    'PericardialCells3':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 9 (python):
```python
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_299748/1379983619.py in <module>
     65     'InnateLymphoidCells':'#72497f',
     66 }
---> 67 sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)
     68 
     69 MidGrainPalette={

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in umap(adata, **kwargs)
    657     tl.umap
    658     """
--> 659     return embedding(adata, 'umap', **kwargs)
    660 
    661 

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in embedding(adata, basis, color, gene_symbols, use_raw, sort_order, edges, edges_width, edges_color, neighbors_key, arrows, arrows_kwds, groups, components, layer, projection, scale_factor, color_map, cmap, palette, na_color, na_in_legend, size, frameon, legend_fontsize, legend_fontweight, legend_loc, legend_fontoutline, vmax, vmin, vcenter, norm, add_outline, outline_width, outline_color, ncols, hspace, wspace, title, show, save, ax, return_fig, **kwargs)
    250             groups=groups,
    251         )
--> 252         color_vector, categorical = _color_vector(
    253             adata,
    254             value_to_plot,

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in _color_vector(adata, values_key, values, palette, na_color)
   1267         color_map = {
   1268             k: to_hex(v)
-> 1269             for k, v in _get_palette(adata, values_key, palette=palette).items()
   1270         }
   1271         # If color_map does not have unique values, this can be slow as the

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in _get_palette(adata, values_key, palette)
   1233     values = pd.Categorical(adata.obs[values_key])
   1234     if palette:
-> 1235         _utils._set_colors_for_categorical_obs(adata, values_key, palette)
   1236     elif color_key not in adata.uns or len(adata.uns[color_key]) < len(
   1237         values.categories

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_utils.py in _set_colors_for_categorical_obs(adata, value_to_plot, palette)
    388         colors_list = [to_hex(x) for x in cmap(np.linspace(0, 1, len(categories)))]
    389     elif isinstance(palette, cabc.Mapping):
--> 390         colors_list = [to_hex(palette[k], keep_alpha=True) for k in categories]
    391     else:
    392         # check if palette is a list and convert it to a cycler, thus

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_utils.py in <listcomp>(.0)
    388         colors_list = [to_hex(x) for x in cmap(np.linspace(0, 1, len(categories)))]
    389     elif isinstance(palette, cabc.Mapping):
--> 390         colors_list = [to_hex(palette[k], keep_alpha=True) for k in categories]
    391     else:
    392         # check if palette is a list and convert it to a cycler, thus

KeyError: 'AtrioventricularNodePacemakerCells'
```

Example 10 (python):
```python
set(adata.obs.region)
```

Example 11 (unknown):
```unknown
{'aorta',
 'apex',
 'atria',
 'atrial septum',
 'base',
 'ductus arteriosus',
 'heart without node',
 'left ventricle',
 'node',
 'outflow tract',
 'pericardium',
 'pulmonary arches and branches',
 'right ventricle',
 'right ventricle and papillaries',
 'whole sample'}
```

Example 12 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryPericytes','CoronarySmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','GreatVesselSmoothMuscleCells'])].copy()
#adata = adata[adata.obs['coarse_grain'].isin(['Endothelium','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adata = adata[adata.obs['fine_grain'].isin(['CoronaryCapillaryEndothelialCells'])].copy()
#adata=adata[adata.obs.mid_grain=='MuralCells',:].copy()
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 0 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 14 (python):
```python
adata = adata[adata.obs['coarse_grain'].isin(['Endothelium'])].copy()
adata = adata[adata.obs['region'].isin(['whole sample'])].copy()
```

Example 15 (python):
```python
tmp = pd.crosstab(adata.obs['week'],adata.obs['fine_grain'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
```

Example 16 (python):
```python
<matplotlib.legend.Legend at 0x7fe61da6fe50>
```

Example 17 (python):
```python
tmp = pd.crosstab(adata.obs['week'],adata.obs['fine_grain'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
```

Example 18 (python):
```python
<matplotlib.legend.Legend at 0x7fe6237ee4c0>
```

Example 19 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 20 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:07)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1116
```

Example 21 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    326 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'CKAP2L', 'ANP32E', 'HJURP', 'CDCA3', 'RANGAP1', 'NCAPD2', 'CDCA2', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'CBX5', 'CENPA']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    724 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 22 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 23 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:23<00:00,  2.14it/s, loss=576, v_num=1]
```

Example 24 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    536 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBE1', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    224 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:04)
```

Example 25 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 26 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 27 (python):
```python
EndothelialStalkGenes=['ACKR1','AQP1','C1QTNF9','CD36','CSRP2','EHD4','FBLN5','HSPB1','IL6ST','JAM2','LGALS3','LRG1','MEOX2','PLSCR2','CAVIN2','SELP','SPINT2','TGFBI','TGM2','TMEM176A','TMEM176B','TMEM252','TSPAN7','FLT1','VWF']
EndothelialStalkGenes = [x for x in EndothelialStalkGenes if x in adata.var_names]
print(len(EndothelialStalkGenes))
EndothelialTipGenes=['ADM','ANKRD37','C1QTNF6','CLDN5','COL4A1','COL4A2','COTL1','DLL4','EDNRB','FSCN1','GPIHBP1','HSPG2','IGFBP3','INHBB','JUP','KCNE3','KCNJ8','LAMA4','LAMB1','LXN','MARCKSL1','MCAM','MEST','N4BP3','NID2','NOTCH4','PLOD1','PLXND1','PMEPA1','PTN','RAMP3','RBP1','RGCC','RHOC','UNC5B','KDR','FLT4']
EndothelialTipGenes = [x for x in EndothelialTipGenes if x in adata.var_names]
print(len(EndothelialTipGenes))

sc.tl.score_genes(adata, EndothelialStalkGenes, score_name='EndothelialStalkScore',ctrl_size=50, gene_pool=None, n_bins=25, random_state=0, copy=False, use_raw=None)
sc.tl.score_genes(adata, EndothelialTipGenes, score_name='EndothelialTipScore',ctrl_size=50, gene_pool=None, n_bins=25, random_state=0, copy=False, use_raw=None)
sc.pl.umap(adata, color=['EndothelialStalkScore','EndothelialTipScore'])

adata.obs['TipOrStalk']= 'Tip'
adata.obs['TipOrStalk'][[x for x in adata.obs_names if adata.obs.EndothelialStalkScore[x]>adata.obs.EndothelialTipScore[x]]]='Stalk'
sc.pl.umap(adata, color=['TipOrStalk'])

plt.rcParams['figure.figsize'] = [3,2]
tmp=pd.crosstab(adata.obs['week'],adata.obs['TipOrStalk'],normalize='index')
tmp.plot.bar(stacked=True,color = ["gold","coral"]).legend(loc='center left',bbox_to_anchor=(1.0,0.5))
plt.title('Coronary Capillary Endothelial Cells')
plt.ylabel('proportion')
```

Example 28 (python):
```python
9
14
computing score 'EndothelialStalkScore'
    finished: added
    'EndothelialStalkScore', score of gene set (adata.obs).
    267 total control genes are used. (0:00:00)
computing score 'EndothelialTipScore'
    finished: added
    'EndothelialTipScore', score of gene set (adata.obs).
    275 total control genes are used. (0:00:00)
```

Example 29 (unknown):
```unknown
... storing 'TipOrStalk' as categorical
```

Example 30 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 31 (python):
```python
sc.tl.rank_genes_groups(adata, 'TipOrStalk', method='t-test', key_added = "t-test")

ClusterOfInterest='Tip'
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='TipOrStalk',standard_scale='var',cmap='YlGn')

ClusterOfInterest='Stalk'
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='TipOrStalk',standard_scale='var',cmap='YlGn')
```

Example 32 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 33 (python):
```python
sc.tl.leiden(adata, resolution=0.25, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')

sc.tl.rank_genes_groups(adata, 'leiden', method='t-test', key_added = "t-test")

ClusterOfInterest='0'
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='leiden',standard_scale='var',cmap='YlGn')
```

Example 34 (python):
```python
running Leiden clustering
    finished: found 5 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 35 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 36 (python):
```python
plt.rcParams['figure.figsize'] = [3,2]
tmp=pd.crosstab(adata.obs['week'],adata.obs['TipOrStalk'],normalize='index')
tmp.plot.bar(stacked=True,color = ["gold","coral"]).legend(loc='center left',bbox_to_anchor=(1.0,0.5))
plt.title('Coronary Capillary Endothelial Cells')
plt.ylabel('proportion')
```

Example 37 (unknown):
```unknown
Text(0, 0.5, 'proportion')
```

Example 38 (python):
```python
bdata=adata[adata.obs.TipOrStalk=='Tip',:].copy()
bdatanames=bdata.obs_names
np.savetxt('Index/TipVsStalkCapillaryEndothelial/TipBarcodes.txt', bdatanames, delimiter="\n", fmt="%s")

bdata=adata[adata.obs.TipOrStalk=='Stalk',:].copy()
bdatanames=bdata.obs_names
np.savetxt('Index/TipVsStalkCapillaryEndothelial/StalkBarcodes.txt', bdatanames, delimiter="\n", fmt="%s")
```

Example 39 (python):
```python
tmp = pd.crosstab(adata.obs['week'],adata.obs['fine_grain'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower right')
```

Example 40 (python):
```python
<matplotlib.legend.Legend at 0x7f306f482c40>
```

Example 41 (python):
```python
StalkGenes=['ACKR1','AQP1','C1QTNF9','CD36','CSRP2','EHD4','FBLN5','HSPB1','IL6ST','JAM2','LGALS3','LRG1','MEOX2','PLSCR2','CAVIN2','SELP','SPINT2','TGFBI','TGM2','TMEM176A','TMEM176B','TMEM252','TSPAN7','FLT1','VWF']
TipGenes=['ADM','ANKRD37','C1QTNF6','CLDN5','COL4A1','COL4A2','COTL1','DLL4','EDNRB','FSCN1','GPIHBP1','HSPG2','IGFBP3','INHBB','JUP','KCNE3','KCNJ8','LAMA4','LAMB1','LXN','MARCKSL1','MCAM','MEST','N4BP3','NID2','NOTCH4','PLOD1','PLXND1','PMEPA1','PTN','RAMP3','RBP1','RGCC','RHOC','UNC5B','KDR','FLT4']
sc.tl.score_genes(adata, StalkGenes, score_name='stalk_score')
sc.tl.score_genes(adata, TipGenes, score_name='tip_score')
sc.pl.umap(adata, color=['tip_score','week','fine_grain'])
sc.pl.dotplot(adata, ['tip_score','stalk_score'] ,groupby='week',categories_order=['4W', '5W', '6W', '7W', '8W', '9W', '10W', '12W', '13W', '14W', '15W', '20W'],standard_scale='var',cmap='YlGn')
sc.pl.dotplot(adata, ['tip_score'] ,groupby='week',categories_order=['4W', '5W', '6W', '7W', '8W', '9W', '10W', '12W', '13W', '14W', '15W', '20W'],standard_scale='var',cmap='YlGn')
```

Example 42 (python):
```python
computing score 'stalk_score'
WARNING: genes are not in var_names and ignored: ['CSRP2', 'EHD4', 'HSPB1', 'IL6ST', 'JAM2', 'LRG1', 'PLSCR2', 'CAVIN2', 'TMEM176A', 'TMEM176B', 'TMEM252']
    finished: added
    'stalk_score', score of gene set (adata.obs).
    483 total control genes are used. (0:00:00)
computing score 'tip_score'
WARNING: genes are not in var_names and ignored: ['C1QTNF6', 'COL4A1', 'COL4A2', 'COTL1', 'FSCN1', 'INHBB', 'JUP', 'KCNJ8', 'LAMB1', 'LXN', 'MARCKSL1', 'MEST', 'N4BP3', 'NID2', 'PLOD1', 'PLXND1', 'PMEPA1', 'PTN', 'RBP1', 'RHOC', 'KDR', 'FLT4']
    finished: added
    'tip_score', score of gene set (adata.obs).
    333 total control genes are used. (0:00:00)
```

Example 43 (python):
```python
sc.tl.leiden(adata, resolution=0.25, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 44 (python):
```python
running Leiden clustering
    finished: found 5 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 45 (python):
```python
bdata=adata[adata.obs.fine_grain=='CoronaryCapillaryEndothelialCells',:].copy()
bdata=bdata[bdata.obs.leiden!='4',:].copy()
StalkGenes=['ACKR1','AQP1','C1QTNF9','CD36','CSRP2','EHD4','FBLN5','HSPB1','IL6ST','JAM2','LGALS3','LRG1','MEOX2','PLSCR2','CAVIN2','SELP','SPINT2','TGFBI','TGM2','TMEM176A','TMEM176B','TMEM252','TSPAN7','FLT1','VWF']
TipGenes=['ADM','ANKRD37','C1QTNF6','CLDN5','COL4A1','COL4A2','COTL1','DLL4','EDNRB','FSCN1','GPIHBP1','HSPG2','IGFBP3','INHBB','JUP','KCNE3','KCNJ8','LAMA4','LAMB1','LXN','MARCKSL1','MCAM','MEST','N4BP3','NID2','NOTCH4','PLOD1','PLXND1','PMEPA1','PTN','RAMP3','RBP1','RGCC','RHOC','UNC5B','KDR','FLT4']
sc.tl.score_genes(bdata, StalkGenes, score_name='stalk_score')
sc.tl.score_genes(bdata, TipGenes, score_name='tip_score')
sc.pl.umap(bdata, color=['tip_score','stalk_score','week','fine_grain'])
sc.pl.dotplot(bdata, ['tip_score','stalk_score'] ,groupby='week',categories_order=['4W', '5W', '6W', '7W', '8W', '9W', '10W', '12W', '13W', '14W', '15W', '20W'],standard_scale='var',cmap='YlGn')
sc.pl.dotplot(bdata, ['tip_score'] ,groupby='week',categories_order=['4W', '5W', '6W', '7W', '8W', '9W', '10W', '12W', '13W', '14W', '15W', '20W'],standard_scale='var',cmap='YlGn')
```

Example 46 (python):
```python
computing score 'stalk_score'
WARNING: genes are not in var_names and ignored: ['CSRP2', 'EHD4', 'HSPB1', 'IL6ST', 'JAM2', 'LRG1', 'PLSCR2', 'CAVIN2', 'TMEM176A', 'TMEM176B', 'TMEM252']
    finished: added
    'stalk_score', score of gene set (adata.obs).
    583 total control genes are used. (0:00:00)
computing score 'tip_score'
WARNING: genes are not in var_names and ignored: ['C1QTNF6', 'COL4A1', 'COL4A2', 'COTL1', 'FSCN1', 'INHBB', 'JUP', 'KCNJ8', 'LAMB1', 'LXN', 'MARCKSL1', 'MEST', 'N4BP3', 'NID2', 'PLOD1', 'PLXND1', 'PMEPA1', 'PTN', 'RBP1', 'RHOC', 'KDR', 'FLT4']
    finished: added
    'tip_score', score of gene set (adata.obs).
    330 total control genes are used. (0:00:00)
```

Example 47 (python):
```python
sc.pp.neighbors(bdata, use_rep="X_scVI")
sc.tl.umap(bdata,min_dist=0.1)
sc.tl.leiden(bdata, resolution=0.25, key_added='leiden')
sc.pl.umap(bdata, color='leiden',legend_loc='on data')
```

Example 48 (python):
```python
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:00)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:03)
running Leiden clustering
    finished: found 4 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 49 (python):
```python
cdata=bdata[bdata.obs.leiden=='1',:].copy()
StalkGenes=['ACKR1','AQP1','C1QTNF9','CD36','CSRP2','EHD4','FBLN5','HSPB1','IL6ST','JAM2','LGALS3','LRG1','MEOX2','PLSCR2','CAVIN2','SELP','SPINT2','TGFBI','TGM2','TMEM176A','TMEM176B','TMEM252','TSPAN7','FLT1','VWF']
TipGenes=['ADM','ANKRD37','C1QTNF6','CLDN5','COL4A1','COL4A2','COTL1','DLL4','EDNRB','FSCN1','GPIHBP1','HSPG2','IGFBP3','INHBB','JUP','KCNE3','KCNJ8','LAMA4','LAMB1','LXN','MARCKSL1','MCAM','MEST','N4BP3','NID2','NOTCH4','PLOD1','PLXND1','PMEPA1','PTN','RAMP3','RBP1','RGCC','RHOC','UNC5B','KDR','FLT4']
sc.tl.score_genes(cdata, StalkGenes, score_name='stalk_score')
sc.tl.score_genes(cdata, TipGenes, score_name='tip_score')
sc.pl.umap(cdata, color=['tip_score','stalk_score','week','fine_grain'])
sc.pl.dotplot(cdata, ['tip_score','stalk_score'] ,groupby='week',categories_order=['4W', '5W', '6W', '7W', '8W', '9W', '10W', '12W', '13W', '14W', '15W', '20W'],standard_scale='var',cmap='YlGn')
sc.pl.dotplot(cdata, ['tip_score'] ,groupby='week',categories_order=['4W', '5W', '6W', '7W', '8W', '9W', '10W', '12W', '13W', '14W', '15W', '20W'],standard_scale='var',cmap='YlGn')
```

Example 50 (python):
```python
computing score 'stalk_score'
WARNING: genes are not in var_names and ignored: ['CSRP2', 'EHD4', 'HSPB1', 'IL6ST', 'JAM2', 'LRG1', 'PLSCR2', 'CAVIN2', 'TMEM176A', 'TMEM176B', 'TMEM252']
    finished: added
    'stalk_score', score of gene set (adata.obs).
    586 total control genes are used. (0:00:00)
computing score 'tip_score'
WARNING: genes are not in var_names and ignored: ['C1QTNF6', 'COL4A1', 'COL4A2', 'COTL1', 'FSCN1', 'INHBB', 'JUP', 'KCNJ8', 'LAMB1', 'LXN', 'MARCKSL1', 'MEST', 'N4BP3', 'NID2', 'PLOD1', 'PLXND1', 'PMEPA1', 'PTN', 'RBP1', 'RHOC', 'KDR', 'FLT4']
    finished: added
    'tip_score', score of gene set (adata.obs).
    330 total control genes are used. (0:00:00)
```

Example 51 (python):
```python
sc.pl.umap(bdata, color=['tip_score','stalk_score','week','fine_grain'])
```

Example 52 (python):
```python
ClusterOfInterest='1'
sc.tl.rank_genes_groups(bdata, 'leiden', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:50]]
sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='leiden',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 53 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 54 (python):
```python
bdata=adata[adata.obs.fine_grain=='CoronaryCapillaryEndothelialCells',:].copy()
StalkandTipGenes=['ACKR1','AQP1','C1QTNF9','CD36','CSRP2','EHD4','FBLN5','HSPB1','IL6ST','JAM2','LGALS3','LRG1','MEOX2','PLSCR2','CAVIN2','SELP','SPINT2','TGFBI','TGM2','TMEM176A','TMEM176B','TMEM252','TSPAN7','FLT1','VWF','ADM','ANKRD37','C1QTNF6','CLDN5','COL4A1','COL4A2','COTL1','DLL4','EDNRB','FSCN1','GPIHBP1','HSPG2','IGFBP3','INHBB','JUP','KCNE3','KCNJ8','LAMA4','LAMB1','LXN','MARCKSL1','MCAM','MEST','N4BP3','NID2','NOTCH4','PLOD1','PLXND1','PMEPA1','PTN','RAMP3','RBP1','RGCC','RHOC','UNC5B','KDR','FLT4']
bdata=bdata[:,[x for x in bdata.var_names if x  in StalkandTipGenes]].copy()
```

Example 55 (python):
```python
sc.pp.neighbors(bdata, use_rep="X_scVI")
sc.tl.umap(bdata,min_dist=0.1)
```

Example 56 (python):
```python
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:03)
```

Example 57 (python):
```python
sc.pl.umap(bdata, color='tip_score')
```

Example 58 (python):
```python
sc.pl.umap(bdata, color='stalk_score')
```

Example 59 (python):
```python
ClusterOfInterest='0'
sc.tl.rank_genes_groups(adata, 'leiden', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='leiden',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 60 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 61 (python):
```python
set(adata.obs.fine_grain)
```

Example 62 (unknown):
```unknown
{'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryVenousEndothelialCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselVenousEndothelialCells',
 'LymphaticEndothelialCells',
 'ValveEndothelialCells'}
```

Example 63 (python):
```python
pd.crosstab(adata.obs['fine_grain'],adata.obs['age'])
```

Example 64 (python):
```python
adata.obs['type']= 'na'
adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['LymphaticEndothelialCells']]]='Yes'
tmp = pd.crosstab(adata.obs['week'],adata.obs['type'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='lower right')
```

Example 65 (python):
```python
<matplotlib.legend.Legend at 0x7f2df6be6be0>
```

Example 66 (python):
```python
adata.obs['type']= 'na'
adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['CoronaryCapillaryEndothelialCells']]]='Yes'
tmp = pd.crosstab(adata.obs['week'],adata.obs['fine_grain'], normalize='index')
tmp.plot.bar(stacked=True).legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
```

Example 67 (python):
```python
<matplotlib.legend.Legend at 0x7f2df9a5aa90>
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_EndocardialCells.html

**Contents:**
- Variables¶
- Read in data¶
- Markers¶
- 1st round annotation¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 0 has lower total counts and smaller cell area, and no specific gene expression --> annotate as "unassigned"

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-09 22:25
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'EndocardialCells'
```

Example 10 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 5202 × 4492
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([3.6159909, 2.569763 , 2.569763 , 3.2238812, 2.569763 ],
      dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 3.72 s, sys: 86.5 ms, total: 3.81 s
Wall time: 3.82 s
```

Example 21 (python):
```python
# read in markers identified using single-nucleus data
markers_df = pd.read_csv(f'/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_{celltype}_finegrain_markers.csv')

mask1 = markers_df['group_mean']>1
mask2 = markers_df['logfoldchanges']>1
markers_df = markers_df[mask1&mask2]

markers_df
```

Example 22 (python):
```python
markers = {}
n_top = 20
for c in set(markers_df['group']):
    markers_df_sub = markers_df[markers_df['group']==c]
    markers_df_sub.sort_values('logfoldchanges',ascending=False)
    markers[c]=list(markers_df_sub[:n_top]['names'])

# manually add genes
markers['Cycling'] = ['MKI67','TOP2A'] 

genes = []
for g in markers.values():
    genes = genes + [x for x in g if (x in list(adata.var_names))&(x not in genes)]
for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in list(adata.var_names)]
len(genes)
```

Example 23 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",color=genes, size=20,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 24 (python):
```python
sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",
                color=['celltypist_midmod2fine', 'conf_score_midmod2fine'],
                wspace=0.7)
```

Example 25 (python):
```python
# umap per celltype to highlight
group_col = 'celltypist_midmod2fine'
groups_to_plot = list(set(adata.obs[group_col]))

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,7))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata,basis=f"X_umap_{latent_space}",
                    color=[group_col], groups=grp, 
               size=30, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 26 (unknown):
```unknown
resolution_sel = 0.6
```

Example 27 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              markers_others, 
              groupby=f'leiden_{str(resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 28 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 29 (python):
```python
sc.tl.dendrogram(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby=f'leiden_{str(resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 30 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: ValveEndothelialCells, EndocardialCushionCells, EndocardialCells, etc.
```

Example 31 (python):
```python
print(adata.X.data[:5])
adata.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata,groupby=f'leiden_{str(resolution_sel)}')
sc.tl.dendrogram(adata, groupby=f'leiden_{str(resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 32 (unknown):
```unknown
[3.6159909 2.569763  2.569763  3.2238812 2.569763 ]
```

Example 33 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 34 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(resolution_sel)}',legend_loc='on data',
                )
```

Example 35 (unknown):
```unknown
'EndocardialCells'
```

Example 36 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'unassigned',
    '1':'EndocardialCells',
    '2':'EndocardialCells',
    '3':'EndocardialCells',
    '4':'EndocardialCells',
    '5':'Erythrocytes',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 37 (python):
```python
/tmp/ipykernel_69127/744100964.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 38 (unknown):
```unknown
tmp_annotation
EndocardialCells    3569
unassigned          1614
Erythrocytes          19
Name: count, dtype: int64
```

Example 39 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation'
                )
```

Example 40 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation'].isin(['EndocardialCells'])]
```

Example 41 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 42 (unknown):
```unknown
AnnData object with n_obs × n_vars = 3569 × 4492
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.6', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 43 (python):
```python
## Remove mid-grain markers from the feature
# read in markers
midgrain_markers = pd.read_csv('/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/notebooks/Foetal/VisiumHD/re-seq_mpp0p3/sc_midgrain_markers.csv',
                               index_col=0)
# remove the markers of celltype of interest
midgrain_markers = midgrain_markers[midgrain_markers['group']!=celltype]
# remove
mask = [x not in list(midgrain_markers['names']) for x in adata_sub.var_names]
bdata = adata_sub[:,mask]
bdata
```

Example 44 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 3569 × 4027
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'dendrogram_leiden_0.6', 'rank_genes_groups', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 45 (python):
```python
'''
# remove cell cycle genes
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP',
                'RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2',
                'USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67',
                'TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1',
                'CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF',
                'NEK2','G2E3','GAS2L3','CBX5','CENPA']
mask = [x not in cell_cycle_genes for x in bdata.var_names]
bdata = bdata[:,mask]
bdata.shape
'''
```

Example 46 (python):
```python
# HVGs, using the object which doesn't have midgrain markers
sc.pp.highly_variable_genes(bdata, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
print(f'number of hvgs: {sum(bdata.var.highly_variable)}')
# PCA using the degected HVGs
sc.tl.pca(bdata, use_highly_variable=True)
adata_sub.obsm['X_pca'] = bdata.obsm['X_pca'].copy()
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 47 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_highly_variable_genes.py:698: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  adata.uns["hvg"] = {"flavor": flavor}
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
```

Example 48 (unknown):
```unknown
number of hvgs: 733
```

Example 49 (python):
```python
2025-06-09 22:29:47,867 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-09 22:29:49,453 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-09 22:29:49,467 - harmonypy - INFO - Iteration 1 of 10
2025-06-09 22:29:49,847 - harmonypy - INFO - Iteration 2 of 10
2025-06-09 22:29:50,229 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 50 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 51 (unknown):
```unknown
CPU times: user 5.2 s, sys: 110 ms, total: 5.31 s
Wall time: 5.33 s
```

Example 52 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",size=10,
                color=genes,
               ncols=6, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 53 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=["conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 54 (python):
```python
# umap per celltype to highlight
group_col = 'celltypist_midmod2fine'
groups_to_plot = list(set(adata_sub.obs[group_col]))

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,8))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                    color=[group_col], groups=grp, 
               size=20, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 55 (unknown):
```unknown
sub_resolution_sel = 1.5
```

Example 56 (python):
```python
markers_others = {
    'CM': ['TTN', 'TNNT2','MYH6',
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4'], #aCM
    'FB': ['DCN', 'GCN', 'PDGFRA','COL1A1','COL1A2'],
    'EC': ['VWF', 'PECAM1', 'CDH5','RGCC', 'FABP5',],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3','PRPH', 'NEFL', 'NEFM', 'NEFH', 'STMN2', 'SST', 'SLC10A4', 'SLC18A3', 'TH', 'NPY'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers_others.keys():
    markers_others[key]=[x for x in markers_others[key] if x in adata.var_names]

sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              markers_others, 
              groupby=f'leiden_{str(sub_resolution_sel)}',
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              swap_axes=False,
             )
```

Example 57 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: CM, FB, EC, etc.
```

Example 58 (python):
```python
sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 59 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: ValveEndothelialCells, EndocardialCushionCells, EndocardialCells, etc.
```

Example 60 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 61 (unknown):
```unknown
[3.6159909 2.569763  2.569763  3.2238812 2.569763 ]
```

Example 62 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 63 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'EndocardialCells_Doublets',
    '1':'ValveEndothelialCells',
    '2':'EndocardialCellsCycling',
    '3':'EndocardialCells',
    '4':'EndocardialCells',
    '5':'EndocardialCells',
    '6':'EndocardialCushionCells',
    '7':'EndocardialCushionCells',
    '8':'EndocardialCells',
    '9':'ValveEndothelialCells',
    '10':'EndocardialCells',
    '11':'EndocardialCells',
    '12':'EndocardialCells',
    '13':'EndocardialCells',
    '14':'ValveEndothelialCells',
    '15':'EndocardialCells',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 64 (python):
```python
/tmp/ipykernel_69127/3524787546.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 65 (unknown):
```unknown
fine_grain_manual
EndocardialCells             1670
ValveEndothelialCells         635
EndocardialCells_Doublets     474
EndocardialCushionCells       432
EndocardialCellsCycling       358
Name: count, dtype: int64
```

Example 66 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 67 (python):
```python
sc.tl.dendrogram(adata_sub,groupby='fine_grain_manual')
sc.pl.dotplot(adata_sub,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 68 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: EndocardialCells_Doublets, ValveEndothelialCells, EndocardialCellsCycling, etc.
var_group_labels: ValveEndothelialCells, EndocardialCushionCells, EndocardialCells, etc.
```

Example 69 (python):
```python
adata.obs['fine_grain_manual'] = adata.obs['tmp_annotation'].astype('str').copy()
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 70 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual'
                )
```

Example 71 (python):
```python
sc.tl.dendrogram(adata,groupby='fine_grain_manual')
sc.pl.dotplot(adata,
              var_names=markers,
              groupby='fine_grain_manual',
              standard_scale='var',
              dendrogram=True
             )
```

Example 72 (unknown):
```unknown
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: EndocardialCells, EndocardialCellsCycling, EndocardialCells_Doublets, etc.
var_group_labels: ValveEndothelialCells, EndocardialCushionCells, EndocardialCells, etc.
```

Example 73 (python):
```python
for ct in set(adata.obs['fine_grain_manual']):
    for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
        slide = adata[adata.obs['tissue_block_id']==tissue_id]
        sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
                      spot_size=60,vmax='p100')
```

Example 74 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 75 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 76 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 77 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 78 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 79 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 80 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 81 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 82 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 83 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 84 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 85 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 86 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 87 (python):
```python
/tmp/ipykernel_69127/2414531429.py:4: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups=ct,
```

Example 88 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 89 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_EndocardialCells_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Leukocytes/No1_Immune_pre-scVI.html

**Contents:**
- Import modules¶
- Read in data¶
- Remove C97: uncertain inflammatory signature in C97¶
- Save to gdrive¶

**Examples:**

Example 1 (python):
```python
import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import anndata
import matplotlib.pyplot as plt
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
-----
anndata             0.7.5
matplotlib          3.3.4
numpy               1.20.1
pandas              1.1.4
scanpy              1.7.1
session_info        1.0.0
-----
```

Example 4 (unknown):
```unknown
PIL                 8.1.2
anyio               NA
attr                20.3.0
babel               2.9.0
backcall            0.2.0
brotli              NA
cairo               1.20.0
certifi             2020.12.05
cffi                1.14.5
chardet             4.0.0
cloudpickle         1.6.0
colorama            0.4.4
cycler              0.10.0
cython_runtime      NA
cytoolz             0.11.0
dask                2021.03.1
dateutil            2.8.1
decorator           4.4.2
fsspec              0.8.7
get_version         2.1
google              NA
h5py                2.10.0
idna                2.10
igraph              0.8.3
ipykernel           5.5.0
ipython_genutils    0.2.0
jedi                0.18.0
jinja2              2.11.3
joblib              1.0.1
json5               NA
jsonschema          3.2.0
jupyter_server      1.4.1
jupyterlab_server   2.3.0
kiwisolver          1.3.1
legacy_api_wrap     0.0.0
leidenalg           0.8.3
llvmlite            0.34.0
louvain             0.7.0
markupsafe          1.1.1
mpl_toolkits        NA
natsort             7.1.1
nbclassic           NA
nbformat            5.1.2
numba               0.51.2
numexpr             2.7.3
packaging           20.9
parso               0.8.1
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
prometheus_client   NA
prompt_toolkit      3.0.16
psutil              5.8.0
ptyprocess          0.7.0
pvectorc            NA
pyarrow             0.16.0
pygments            2.8.0
pyparsing           2.4.7
pyrsistent          NA
pytoml              NA
pytz                2021.1
requests            2.25.1
ruamel              NA
scipy               1.6.1
send2trash          NA
setuptools_scm      NA
simplejson          3.17.2
sinfo               0.3.1
six                 1.15.0
sklearn             0.22
sniffio             1.2.0
socks               1.7.1
sphinxcontrib       NA
storemagic          NA
tables              3.6.1
tblib               1.7.0
texttable           1.6.3
tlz                 0.11.0
toolz               0.11.1
tornado             6.1
traitlets           5.0.5
typing_extensions   NA
uritemplate         3.0.1
urllib3             1.26.3
wcwidth             0.2.5
yaml                5.1.2
zmq                 22.0.3
```

Example 5 (unknown):
```unknown
-----
IPython             7.21.0
jupyter_client      6.1.11
jupyter_core        4.7.1
jupyterlab          3.0.9
notebook            6.2.0
-----
Python 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:22:27) [GCC 9.3.0]
Linux-4.15.0-112-generic-x86_64-with-glibc2.10
-----
Session information updated at 2023-02-16 10:25
```

Example 6 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=200, color_map = 'RdPu',)
```

Example 7 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/14Feb_fromSemih/14FebImmuneForKazumasa.h5ad')
print(adata.X.data[:10])
adata
```

Example 8 (unknown):
```unknown
[1. 2. 1. 1. 1. 2. 2. 5. 2. 2.]
```

Example 9 (unknown):
```unknown
AnnData object with n_obs × n_vars = 49042 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', 'age_colors', 'cell_or_nuclei_colors', 'donor_colors', 'modality_colors', 'sex_colors', 'trimester_colors', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_continuous', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 10 (python):
```python
adata.obs['week'].value_counts()
```

Example 11 (unknown):
```unknown
20W    22643
6W      8120
8W      5563
7W      5209
9W      2324
10W     1912
13W     1261
15W     1038
5W       520
14W      207
12W      188
4W        57
Name: week, dtype: int64
```

Example 12 (python):
```python
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=['leiden_scVI','2Jan_mid_grain','2Jan_fine_grain'], size=0.5, wspace=0.1, legend_loc='on data', legend_fontsize=5)
```

Example 13 (python):
```python
adata_lognorm = adata.copy()
sc.pp.normalize_total(adata_lognorm, target_sum=1e4)
sc.pp.log1p(adata_lognorm)
```

Example 14 (unknown):
```unknown
normalizing counts per cell
    finished (0:00:00)
```

Example 15 (python):
```python
inflam_genes=['TNF','IL1B','IL1A','IL6','CXCL1','CXCL2','CXCL8','CCL2']
inflam_genes = [x for x in inflam_genes if x in adata_lognorm.var_names]
sc.tl.score_genes(adata_lognorm, inflam_genes, score_name='inflammatory')
sc.pl.violin(adata_lognorm, keys='inflammatory', groupby='donor', rotation=90, jitter=False)
```

Example 16 (python):
```python
computing score 'inflammatory'
    finished: added
    'inflammatory', score of gene set (adata.obs).
    200 total control genes are used. (0:00:01)
```

Example 17 (unknown):
```unknown
!ls /nfs/team205/heart/anndata_objects/Foetal/Immune
```

Example 18 (python):
```python
# Remove C97 from Immune cells
## save C97 cell ID
C97_index = adata.obs_names[adata.obs['donor']=='C97']
C97_index.to_series().to_csv('/nfs/team205/heart/anndata_objects/Foetal/Immune/C97_index.csv',index=False)

# remove
adata = adata[adata.obs['donor']!='C97']
pd.crosstab(adata.obs['week'],adata.obs['age'])
```

Example 19 (python):
```python
adata.write(f'/home/jovyan/mount/gdrive/Colab/data/anndata/RNA_foetal_raw_immune_16Feb2023.h5ad')
adata
```

Example 20 (unknown):
```unknown
View of AnnData object with n_obs × n_vars = 41881 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', '_scvi_labels', '2Jan_coarse_grain', '2Jan_mid_grain', '2Jan_fine_grain', 'leiden_scVI', 'FACSgate', 'sex', 'week', 'trimester'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', 'age_colors', 'cell_or_nuclei_colors', 'donor_colors', 'modality_colors', 'sex_colors', 'trimester_colors', 'week_colors', 'leiden_scVI_colors', '2Jan_mid_grain_colors', '2Jan_fine_grain_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_continuous', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Annotations/MesenchymalAnnotation.html

**Examples:**

Example 1 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 2 (python):
```python
adata=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')
print(adata.shape)
```

Example 3 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 4 (python):
```python
# Remove the obvious pericardium and valve cells

sc.pl.umap(adata, color='leiden',groups='8',legend_loc='on data')
PericardialCells = adata.obs.index[adata.obs['leiden'] == '8']

sc.tl.leiden(adata, resolution=0.5, key_added='leiden')
sc.pl.umap(adata, color='leiden',groups='13',legend_loc='on data')

print(len(adata))
adata=adata[adata.obs.leiden!='13',:].copy()
print(len(adata))

adata=adata[[x for x in adata.obs_names if x not in PericardialCells],:].copy()
print(len(adata))
```

Example 5 (python):
```python
set(adata.obs.coarse_grain)
```

Example 6 (python):
```python
adata=adata[adata.obs.coarse_grain=='Mesenchymal',:].copy()
adata
```

Example 7 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata
```

Example 8 (python):
```python
# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
#sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 9 (python):
```python
#this block is to see where the cells over a certain threshold with TNNT2 expression lies in the UMAP
#enter what gene to set threshold for
#when running this box for the first time, comment the starting with 'del'
#then uncomment it for the other ones --- !!!

CellName='Cardio_toremove'
gene='TNNT2'
exp_thresh=2.2
gene_pos=adata.var_names.get_loc(gene)
adata_sel = adata[adata.X[:,gene_pos]>exp_thresh].copy()

l=adata_sel.obs_names
set(l).intersection(adata.obs_names)
print(len(l))

#del adata.obs[CellName]
adata.obs.loc[set(l).intersection(adata.obs_names),CellName]='Yes'
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=[CellName], groups='Yes',size=10, wspace=0.45, legend_fontsize=5, legend_loc='on data',frameon=False)

print(adata)
adata= adata[adata.X[:,gene_pos]<exp_thresh].copy()
print(adata)
```

Example 10 (python):
```python
# Look for previous fine_grains
ClustersToStay=['GreatVesselSmoothMuscleCells','MyocardialInterstitialFibroblasts','Myofibroblasts','ValveInterstitialCells','CoronaryPericytes','CoronarySmoothMuscleCells','CoronaryVesselAdventitialFibroblasts','EarlyGreatVesselCells','GreatVesselAdventitialFibroblasts']
bdata=adata[[x for x in adata.obs_names if adata.obs.previous_fine_grain[x] in ClustersToStay],:].copy()
sc.pl.umap(bdata, color='previous_fine_grain')
```

Example 11 (python):
```python
sc.tl.leiden(adata, resolution=0.1, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 12 (python):
```python
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)
```

Example 13 (python):
```python
sc.tl.leiden(adata, resolution=0.075, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 14 (python):
```python
sc.pl.umap(adata, color=['FOXC1','MYH11','PDGFRB','PDGFRA','DCN','TCF21','CLU','GDF10'],legend_loc='on data')
```

Example 15 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 16 (python):
```python
#adata.write('./Objects/MesenchymalWithoutPericardiumAndValves.h5ad')
#adata=sc.read('./Objects/MesenchymalWithoutPericardiumAndValves.h5ad')
```

Example 17 (python):
```python
#Re-run individual mesenchymal compartments
#Great vessel smooth muscle cells

adata=sc.read('./Objects/MesenchymalWithoutPericardiumAndValves.h5ad')
adata=adata[adata.obs.leiden=='2',:].copy()
print(len(adata))
adata_raw=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')

print(adata_raw)
# constructing new anndata with maintaining .obs, .obsm, .obsp, .uns
# overwriting adata_raw
adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp, # from annotated or subsetted data
                    uns=adata.uns # from annotated or subsetted data
                               )

adata=adata_raw.copy()
print(adata)

# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

#sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 18 (python):
```python
sc.tl.leiden(adata, resolution=0.69, key_added='leiden')
sc.pl.umap(adata, color='leiden',groups='8',legend_loc='on data')
sc.pl.umap(adata, color=['RGS5','ROBO2','DCLK2','PDE1C','IL17B'])
```

Example 19 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 20 (python):
```python
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 21 (python):
```python
#Re-run individual mesenchymal compartments
#Early great vessel cells

adata=sc.read('./Objects/MesenchymalWithoutPericardiumAndValves.h5ad')
adata=adata[adata.obs.leiden=='3',:].copy()
print(len(adata))
adata_raw=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')

print(adata_raw)
# constructing new anndata with maintaining .obs, .obsm, .obsp, .uns
# overwriting adata_raw
adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp, # from annotated or subsetted data
                    uns=adata.uns # from annotated or subsetted data
                               )

adata=adata_raw.copy()
print(adata)

# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
#sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 22 (python):
```python
sc.pl.umap(adata, color='previous_fine_grain')
```

Example 23 (python):
```python
# Look for previous fine_grains
ClustersToStay=['NA','GreatVesselSmoothMuscleCells','MyocardialInterstitialFibroblasts','Myofibroblasts','ValveInterstitialCells','CoronaryPericytes','CoronarySmoothMuscleCells','CoronaryVesselAdventitialFibroblasts','EarlyGreatVesselCells','GreatVesselAdventitialFibroblasts']
bdata=adata[[x for x in adata.obs_names if adata.obs.previous_fine_grain[x] in ClustersToStay],:].copy()
sc.pl.umap(bdata, color='previous_fine_grain')
```

Example 24 (python):
```python
sc.tl.leiden(adata, resolution=0.2, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')

sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 25 (python):
```python
#Re-run individual mesenchymal compartments
#Great vessel adventitial fibroblasts

adata=sc.read('./Objects/MesenchymalWithoutPericardiumAndValves.h5ad')
adata=adata[adata.obs.leiden=='0',:].copy()
print(len(adata))
adata_raw=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')

print(adata_raw)
# constructing new anndata with maintaining .obs, .obsm, .obsp, .uns
# overwriting adata_raw
adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp, # from annotated or subsetted data
                    uns=adata.uns # from annotated or subsetted data
                               )

adata=adata_raw.copy()
print(adata)

# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

#sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 26 (python):
```python
sc.tl.leiden(adata, resolution=0.2, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')

sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata,groupby='leiden', standard_scale='var')

sc.pl.umap(adata, color=['SRPX','GDF10'],legend_loc='on data')
```

Example 27 (python):
```python
#Re-run individual mesenchymal compartments
#Myocardial fibroblasts and coronary mural cells

adata=sc.read('./Objects/MesenchymalWithoutPericardiumAndValves.h5ad')
adata=adata[adata.obs.leiden=='1',:].copy()
print(len(adata))
adata_raw=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')

print(adata_raw)
# constructing new anndata with maintaining .obs, .obsm, .obsp, .uns
# overwriting adata_raw
adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp, # from annotated or subsetted data
                    uns=adata.uns # from annotated or subsetted data
                               )

adata=adata_raw.copy()
print(adata)

# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','hb2_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 28 (python):
```python
# Look for previous fine_grains
ClustersToStay=['NA','GreatVesselSmoothMuscleCells','MyocardialInterstitialFibroblasts','Myofibroblasts','ValveInterstitialCells','CoronaryPericytes','CoronarySmoothMuscleCells','CoronaryVesselAdventitialFibroblasts','EarlyGreatVesselCells','GreatVesselAdventitialFibroblasts']
bdata=adata[[x for x in adata.obs_names if adata.obs.previous_fine_grain[x] in ClustersToStay],:].copy()
sc.pl.umap(bdata, color='previous_fine_grain')
```

Example 29 (python):
```python
sc.tl.leiden(adata, resolution=2, key_added='leiden')
sc.pl.umap(adata, color='leiden',groups='38',legend_loc='on data')
```

Example 30 (python):
```python
#Remove the TNNT2 cluster
print(adata)
adata=adata[adata.obs.leiden!='38',:].copy()
print(adata)
```

Example 31 (python):
```python
sc.tl.leiden(adata, resolution=0.1, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 32 (python):
```python
adata=adata[adata.obs.leiden=='1',:].copy()
#adata.write('./CoronaryMuralCells.h5ad')
#adata=sc.read('./CoronaryMuralCells.h5ad')
```

Example 33 (python):
```python
#Re-run individual mesenchymal compartments
#Remaining myocardial fibroblasts

adata=sc.read('./Objects/MesenchymalWithoutPericardiumAndValves.h5ad')
adata=adata[adata.obs.leiden=='1',:].copy()

CoronaryPericytes=[x.strip() for x in open('./Index/Mesenchymal/CoronaryPericytes.txt')]
CoronarySmoothMuscleCells=[x.strip() for x in open('./Index/Mesenchymal/CoronarySmoothMuscleCells.txt')]
RBCsRemovedFromMyocardialFibroblasts=[x.strip() for x in open('./RBCsRemovedFromMyocardialFibroblasts.txt')]

ShouldNotBeIn=RBCsRemovedFromMyocardialFibroblasts+CoronarySmoothMuscleCells+CoronaryPericytes
print(len(ShouldNotBeIn))
adata=adata[[x for x in adata.obs_names if x not in ShouldNotBeIn],:].copy()


print(len(adata))
adata_raw=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')

print(adata_raw)
# constructing new anndata with maintaining .obs, .obsm, .obsp, .uns
# overwriting adata_raw
adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp, # from annotated or subsetted data
                    uns=adata.uns # from annotated or subsetted data
                               )

adata=adata_raw.copy()
print(adata)

# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
#sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 34 (python):
```python
sc.pl.umap(adata, color=['FBLN5','CD34','SCN7A','DCN','TCF21','CLU','HAPLN1','ACTA2','PDGFRB','PDGFRA'],legend_loc='on data')
sc.pl.umap(adata, color=['CLU','PDLIM3','NCAM1','HAPLN1','COL9A2','BMPER','SCX','SRPX'],legend_loc='on data')
```

Example 35 (python):
```python
sc.tl.leiden(adata, resolution=0.5, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 36 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 37 (python):
```python
bdata=adata[adata.obs.leiden=='1',:].copy()
bdatanames=bdata.obs_names

np.savetxt('Myofibroblasts.txt', bdatanames, delimiter="\n", fmt="%s")
```

Example 38 (python):
```python
print(len(adata))
adata=adata[adata.obs.leiden!='1',:].copy()
print(len(adata))
```

Example 39 (python):
```python
print(len(adata))
adata=adata[adata.obs.leiden!='2',:].copy()
print(len(adata))
```

Example 40 (python):
```python
bdatanames=adata.obs_names
np.savetxt('MyocardialInterstitialFibroblasts.txt', bdatanames, delimiter="\n", fmt="%s")
```

Example 41 (python):
```python
sc.tl.leiden(adata, resolution=0.2, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 42 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 43 (python):
```python
sc.pl.umap(adata, color=['SLIT3','PIEZO2','TSHZ2','FLRT2','PRRX1','MAPK10'],legend_loc='on data')
sc.pl.umap(adata, color=['SCN7A','ROBO2','TLL2'],legend_loc='on data')
sc.pl.umap(adata, color=['region'],groups=['atrial septum','left ventricle','right ventricle + papillary'])
```

Example 44 (python):
```python
#Combine all barcodes

adata=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')
print(adata.shape)

adata=adata[adata.obs.coarse_grain=='Mesenchymal',:].copy()
print(adata.shape)

CoronaryPericytes=[x.strip() for x in open('./Index/Mesenchymal/CoronaryPericytes.txt')]
CoronarySmoothMuscleCells=[x.strip() for x in open('./Index/Mesenchymal/CoronarySmoothMuscleCells.txt')]
CoronaryVesselAdventitialFibroblasts=[x.strip() for x in open('./Index/Mesenchymal/CoronaryVesselAdventitialFibroblasts.txt')]
DuctusArteriosusSmoothMuscleCells=[x.strip() for x in open('./Index/Mesenchymal/DuctusArteriosusSmoothMuscleCells.txt')]
EarlyGreatVesselCells=[x.strip() for x in open('./Index/Mesenchymal/EarlyGreatVesselCells.txt')]
GreatVesselAdventitialFibroblasts=[x.strip() for x in open('./Index/Mesenchymal/GreatVesselAdventitialFibroblasts.txt')]
GreatVesselSmoothMuscleCells=[x.strip() for x in open('./Index/Mesenchymal/GreatVesselSmoothMuscleCells.txt')]
MyocardialInterstitialFibroblasts=[x.strip() for x in open('./Index/Mesenchymal/MyocardialInterstitialFibroblasts.txt')]
Myofibroblasts=[x.strip() for x in open('./Index/Mesenchymal/Myofibroblasts.txt')]
PericardialCells=[x.strip() for x in open('./Index/Mesenchymal/PericardialCells.txt')]
ValveInterstitialCells=[x.strip() for x in open('./Index/Mesenchymal/ValveInterstitialCells.txt')]

MesenchymalIndex=CoronaryPericytes+CoronarySmoothMuscleCells+CoronaryVesselAdventitialFibroblasts+DuctusArteriosusSmoothMuscleCells+EarlyGreatVesselCells+GreatVesselAdventitialFibroblasts+GreatVesselSmoothMuscleCells+MyocardialInterstitialFibroblasts+Myofibroblasts+PericardialCells+ValveInterstitialCells


adata.obs['fine_grain']= 'na'

for k in range(1, len(adata)+1):
    if adata.obs_names[k-1] in CoronaryPericytes:
        adata.obs.fine_grain[k-1]='CoronaryPericytes'   
    if adata.obs_names[k-1] in CoronarySmoothMuscleCells:
        adata.obs.fine_grain[k-1]='CoronarySmoothMuscleCells'  
    if adata.obs_names[k-1] in CoronaryVesselAdventitialFibroblasts:
        adata.obs.fine_grain[k-1]='CoronaryVesselAdventitialFibroblasts'   
    if adata.obs_names[k-1] in DuctusArteriosusSmoothMuscleCells:
        adata.obs.fine_grain[k-1]='DuctusArteriosusSmoothMuscleCells'  
    if adata.obs_names[k-1] in EarlyGreatVesselCells:
        adata.obs.fine_grain[k-1]='EarlyGreatVesselCells'   
    if adata.obs_names[k-1] in GreatVesselSmoothMuscleCells:
        adata.obs.fine_grain[k-1]='GreatVesselSmoothMuscleCells'   
    if adata.obs_names[k-1] in MyocardialInterstitialFibroblasts:
        adata.obs.fine_grain[k-1]='MyocardialInterstitialFibroblasts'   
    if adata.obs_names[k-1] in Myofibroblasts:
        adata.obs.fine_grain[k-1]='Myofibroblasts'  
    if adata.obs_names[k-1] in PericardialCells:
        adata.obs.fine_grain[k-1]='PericardialCells'  
    if adata.obs_names[k-1] in ValveInterstitialCells:
        adata.obs.fine_grain[k-1]='ValveInterstitialCells'  

for k in range(1, len(adata)+1):        
    if adata.obs_names[k-1] in GreatVesselAdventitialFibroblasts:
        adata.obs.fine_grain[k-1]='GreatVesselAdventitialFibroblasts'  

sc.pl.umap(adata, color=['fine_grain'])

print(adata.shape)
adata=adata[adata.obs.fine_grain!='na',:].copy()
print(adata.shape)
```

Example 45 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=20)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
#sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 46 (python):
```python
sc.pl.umap(adata, color='fine_grain')
```

Example 47 (python):
```python
sc.pl.umap(adata, color='age')
```

Example 48 (python):
```python
sc.pl.umap(adata, color='region')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig5_Trisomy21/no01_t21_scVI-for-cleanup.html

**Contents:**
- Import modules¶
- Read in anndata¶
- Pre-process¶
- Setup anndata for scVI¶
- Creating and training a model¶
- Save¶
- Run per condition¶

**Examples:**

Example 1 (python):
```python
# this is for the jupyter notebook at JupyterLab
# to make sys.path between the terminal and Jupyter same
import sys

print(sys.path) # especially the path to site-packages are different... so thats why couldn't find correct package...

# sys.path from terminal at scvi0190_env
# obtained by excuting `python -c "import sys; print('\n'.join(sys.path))"`
sys.path = [
    "/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python39.zip",
    "/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9",
    "/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/lib-dynload",
    "/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages"
]

print(sys.path)
```

Example 2 (unknown):
```unknown
['/nfs/team205/kk18/Analysis/scVI/notebooks', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python39.zip', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/lib-dynload', '', '/nfs/users/nfs_k/kk18/.local/lib/python3.9/site-packages', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages']
['/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python39.zip', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/lib-dynload', '/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages']
```

Example 3 (python):
```python
# import warnings
# warnings.simplefilter("ignore", UserWarning)

import anndata
import matplotlib.pyplot as plt
import seaborn as sns

import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc

import scvi
```

Example 4 (python):
```python
Global seed set to 0
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/flax/core/frozen_dict.py:169: FutureWarning: jax.tree_util.register_keypaths is deprecated, and will be removed in a future release. Please use `register_pytree_with_keys()` instead.
  jax.tree_util.register_keypaths(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/pytorch_lightning/utilities/warnings.py:53: LightningDeprecationWarning: pytorch_lightning.utilities.warnings.rank_zero_deprecation has been deprecated in v1.6 and will be removed in v1.8. Use the equivalent function from the pytorch_lightning.utilities.rank_zero module instead.
  new_rank_zero_deprecation(
/nfs/team205/kk18/miniconda3/envs/scvi0190_env/lib/python3.9/site-packages/pytorch_lightning/utilities/warnings.py:58: LightningDeprecationWarning: The `pytorch_lightning.loggers.base.rank_zero_experiment` is deprecated in v1.7 and will be removed in v1.9. Please use `pytorch_lightning.loggers.logger.rank_zero_experiment` instead.
  return new_rank_zero_deprecation(*args, **kwargs)
```

Example 5 (python):
```python
import gc
import torch
```

Example 6 (python):
```python
import session_info
session_info.show()
```

Example 7 (python):
```python
-----
anndata             0.8.0
matplotlib          3.7.1
numpy               1.23.5
pandas              1.5.3
scanpy              1.9.3
scvi                0.19.0
seaborn             0.12.2
session_info        1.0.0
torch               1.13.1+cu117
-----
```

Example 8 (python):
```python
PIL                 9.4.0
absl                NA
asttokens           NA
attr                22.2.0
backcall            0.2.0
certifi             2022.12.07
cffi                1.15.1
charset_normalizer  3.1.0
chex                0.1.6
comm                0.1.2
contextlib2         NA
cycler              0.10.0
cython_runtime      NA
dateutil            2.8.2
debugpy             1.6.6
decorator           5.1.1
defusedxml          0.7.1
deprecate           0.3.2
docrep              0.3.2
etils               1.1.0
executing           1.2.0
flax                0.6.7
fsspec              2023.3.0
google              NA
h5py                3.8.0
idna                3.4
igraph              0.10.4
importlib_metadata  NA
importlib_resources NA
ipykernel           6.21.3
ipython_genutils    0.2.0
ipywidgets          8.0.4
jax                 0.4.10
jaxlib              0.4.10
jedi                0.18.2
joblib              1.2.0
kiwisolver          1.4.4
leidenalg           0.9.1
llvmlite            0.39.1
ml_collections      NA
ml_dtypes           0.2.0
mpl_toolkits        NA
msgpack             1.0.5
mudata              0.2.1
multipledispatch    0.6.0
natsort             8.3.1
numba               0.56.4
numpyro             0.11.0
nvidia              NA
opt_einsum          v3.3.0
optax               0.1.4
packaging           23.0
parso               0.8.3
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
platformdirs        3.1.1
prompt_toolkit      3.0.38
psutil              5.9.4
ptyprocess          0.7.0
pure_eval           0.2.2
pydev_ipython       NA
pydevconsole        NA
pydevd              2.9.5
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.14.0
pyparsing           3.0.9
pyro                1.8.4
pytorch_lightning   1.7.7
pytz                2022.7.1
requests            2.28.2
rich                NA
scipy               1.10.1
setuptools          65.6.3
six                 1.16.0
sklearn             1.2.2
stack_data          0.6.2
statsmodels         0.13.5
tensorboard         2.12.0
texttable           1.6.7
threadpoolctl       3.1.0
toolz               0.12.0
torchmetrics        0.11.4
torchvision         0.14.1+cu117
tornado             6.2
tqdm                4.65.0
traitlets           5.9.0
tree                0.1.8
typing_extensions   NA
urllib3             1.26.15
wcwidth             0.2.6
yaml                6.0
zipp                NA
zmq                 25.0.1
zoneinfo            NA
```

Example 9 (unknown):
```unknown
-----
IPython             8.11.0
jupyter_client      8.0.3
jupyter_core        5.2.0
notebook            6.5.3
-----
Python 3.9.16 (main, Mar  8 2023, 14:00:05) [GCC 11.2.0]
Linux-4.15.0-222-generic-x86_64-with-glibc2.27
-----
Session information updated at 2024-04-04 22:57
```

Example 10 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=80, facecolor='white', color_map = 'RdPu',)
```

Example 11 (unknown):
```unknown
!ls -lh /nfs/team205/heart/anndata_objects/Foetal/QC/
```

Example 12 (unknown):
```unknown
total 18G
drwxrwsr-x 2 kk18 team205   213 Aug 17  2022 multiome_ATAC
-rw-rw-r-- 1 kk18 team205   11M Feb  8  2023 Multiome_rm-doublets.txt
-rw-rw-r-- 1 kk18 team205  4.3G Feb  8  2023 multiome_RNA_foetal.h5ad
-rw-rw-r-- 1 kk18 team205   12G Feb  8  2023 multiome_RNA_foetal_prefilter.h5ad
-rw-rw-r-- 1 kk18 team205  2.0G Dec 30  2022 scRNA_foetal.h5ad
-rw-rw-r-- 1 kk18 team205  2.6G Dec 12 15:09 scRNA_foetal_include-doublets_13Dec2023.h5ad
-rw-rw-r-- 1 kk18 team205  2.9G Dec 23  2022 scRNA_foetal_prefilter.h5ad
-rw-rw-r-- 1 kk18 team205 1017K Dec 30  2022 scRNA_rm-doublets.txt
-rw-rw-r-- 1 kk18 team205  4.2M Apr  4 22:13 T21_Multiome_rm-doublets.txt
-rw-rw-r-- 1 kk18 team205  2.3G Apr  4 22:16 T21_multiome_RNA_foetal.h5ad
-rw-rw-r-- 1 kk18 team205  5.5G Apr  4 21:46 T21_multiome_RNA_foetal_prefilter.h5ad
```

Example 13 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/QC/T21_multiome_RNA_foetal.h5ad')
adata
```

Example 14 (unknown):
```unknown
AnnData object with n_obs × n_vars = 121452 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key'
    var: 'gene_name', 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts'
    uns: 'sangerID_colors'
    obsm: 'latent_gene_encoding'
```

Example 15 (python):
```python
adata.X.data[:10]
```

Example 16 (unknown):
```unknown
array([ 1.,  2.,  4.,  1.,  3.,  3., 12.,  6.,  2.,  2.], dtype=float32)
```

Example 17 (python):
```python
print(adata.obs['batch_key'].value_counts())
print(adata.obs['cell_or_nuclei'].value_counts())
```

Example 18 (unknown):
```unknown
Hst42_Nuclei_Multiome-v1    70685
Hst32_Nuclei_Multiome-v1    23019
Hst44_Nuclei_Multiome-v1    22517
Hst48_Nuclei_Multiome-v1     5231
Name: batch_key, dtype: int64
Nuclei    121452
Name: cell_or_nuclei, dtype: int64
```

Example 19 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# filter genes
sc.pp.filter_genes(adata, min_cells=3)

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

adata.shape
```

Example 20 (unknown):
```unknown
filtered out 3535 genes that are detected in less than 3 cells
normalizing counts per cell
    finished (0:00:03)
```

Example 21 (unknown):
```unknown
(121452, 33066)
```

Example 22 (python):
```python
# hvg
sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)
```

Example 23 (python):
```python
extracting highly variable genes
    finished (0:00:16)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
3789
```

Example 24 (python):
```python
# freeze the state in `.raw`
# adata.raw = adata
# subset hvgs
adata = adata[:, adata.var.highly_variable]
```

Example 25 (python):
```python
adata = adata.copy()
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])
```

Example 26 (unknown):
```unknown
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
```

Example 27 (python):
```python
vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae
```

Example 28 (unknown):
```unknown
SCVI Model with the following params: 
n_hidden: 128, n_latent: 50, n_layers: 3, dropout_rate: 0.1, dispersion: gene-batch, gene_likelihood: zinb, 
latent_distribution: normal
Training status: Not Trained
```

Example 29 (python):
```python
vae.view_anndata_setup(adata)
```

Example 30 (unknown):
```unknown
Anndata setup with scvi-tools version 0.19.0.
```

Example 31 (unknown):
```unknown
Setup via `SCVI.setup_anndata` with arguments:
```

Example 32 (unknown):
```unknown
{
│   'layer': 'counts',
│   'batch_key': 'batch_key',
│   'labels_key': None,
│   'size_factor_key': None,
│   'categorical_covariate_keys': None,
│   'continuous_covariate_keys': ['total_counts', 'pct_counts_mt', 'pct_counts_ribo']
}
```

Example 33 (unknown):
```unknown
Summary Statistics          
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃     Summary Stat Key     ┃ Value  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━┩
│         n_batch          │   4    │
│         n_cells          │ 121452 │
│ n_extra_categorical_covs │   0    │
│ n_extra_continuous_covs  │   3    │
│         n_labels         │   1    │
│          n_vars          │  3789  │
└──────────────────────────┴────────┘
```

Example 34 (python):
```python
Data Registry                            
┏━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃     Registry Key      ┃            scvi-tools Location            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│           X           │          adata.layers['counts']           │
│         batch         │         adata.obs['_scvi_batch']          │
│ extra_continuous_covs │ adata.obsm['_scvi_extra_continuous_covs'] │
│        labels         │         adata.obs['_scvi_labels']         │
└───────────────────────┴───────────────────────────────────────────┘
```

Example 35 (python):
```python
batch State Registry                            
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃    Source Location     ┃        Categories        ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['batch_key'] │ Hst32_Nuclei_Multiome-v1 │          0          │
│                        │ Hst42_Nuclei_Multiome-v1 │          1          │
│                        │ Hst44_Nuclei_Multiome-v1 │          2          │
│                        │ Hst48_Nuclei_Multiome-v1 │          3          │
└────────────────────────┴──────────────────────────┴─────────────────────┘
```

Example 36 (python):
```python
labels State Registry                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃      Source Location      ┃ Categories ┃ scvi-tools Encoding ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ adata.obs['_scvi_labels'] │     0      │          0          │
└───────────────────────────┴────────────┴─────────────────────┘
```

Example 37 (python):
```python
extra_continuous_covs State   
            Registry            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃       Source Location        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  adata.obs['total_counts']   │
│  adata.obs['pct_counts_mt']  │
│ adata.obs['pct_counts_ribo'] │
└──────────────────────────────┘
```

Example 38 (unknown):
```unknown
# train
vae.train()
```

Example 39 (unknown):
```unknown
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
```

Example 40 (unknown):
```unknown
Epoch 66/66: 100%|██████████| 66/66 [14:43<00:00, 13.02s/it, loss=1.2e+03, v_num=1]
```

Example 41 (unknown):
```unknown
`Trainer.fit` stopped: `max_epochs=66` reached.
```

Example 42 (unknown):
```unknown
Epoch 66/66: 100%|██████████| 66/66 [14:43<00:00, 13.39s/it, loss=1.2e+03, v_num=1]
```

Example 43 (unknown):
```unknown
# save scvi model
vae.save("/nfs/team205/heart/anndata_objects/Foetal/scVI/models/RNA_foetal_T21/",overwrite=True)
```

Example 44 (python):
```python
# save anndata
adata.obsm["X_scVI"] = vae.get_latent_representation()
adata.write('/nfs/team205/heart/anndata_objects/Foetal/scVI/T21_multiome_RNA_foetal_post-scVI.h5ad')
```

Example 45 (python):
```python
# Convergency plot
vae.history['elbo_train']
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
```

Example 46 (python):
```python
set(adata.obs[celltype_col])
```

Example 47 (python):
```python
%%time
for cond in model_architecture_conditions:
    for celltype in set(adata.obs[celltype_col]):
        print(f'##############################')
        print(f'##### {cond}: {celltype} #####')
        print(f'##############################')

        # subset
        adata_sub = adata[adata.obs[celltype_col]==celltype]
        # filter genes
        sc.pp.filter_genes(adata_sub, min_cells=3)

        # setup anndata for scVI
        adata_sub = adata_sub.copy()
        scvi.model.SCVI.setup_anndata(adata_sub, 
                                  # layer="counts", 
                                  categorical_covariate_keys=['batch_key'],
                                  continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo',
                                                             'S_score', 'G2M_score'
                                                            ])
        # creating a model
        if cond == 'three-layer':
            vae = scvi.model.SCVI(adata_sub, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
        elif cond == 'two-layer':
            vae = scvi.model.SCVI(adata_sub, n_hidden=128, n_latent=50, n_layers=2, dispersion = 'gene-batch')
        elif cond == 'one-layer':
            vae = scvi.model.SCVI(adata_sub, n_hidden=128, n_latent=50, n_layers=1, dispersion = 'gene-batch')
        print(vae)
        vae.view_anndata_setup(adata_sub)
        # train
        vae.train()

        # save scvi model
        vae.save(f"/nfs/team205/heart/anndata_objects/Foetal/scVI/models/subsets/Foetal_multiome_{celltype}_{cond}/",overwrite=True)

        # save scVI lagent space
        adata_sub.obsm["X_scVI"] = vae.get_latent_representation()
        adata_sub.write(f'/nfs/team205/heart/anndata_objects/Foetal/scVI/subsets/Foetal_multiome_{celltype}_{cond}.h5ad')

        # Convergency plot
        vae.history['elbo_train']
        x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
        plt.plot(x, vae.history['elbo_train'], label="train")
        plt.xlabel('epoch')
        plt.ylabel('elbo_train')
        plt.title(f'{cond}: {celltype}')
        plt.show()

        del adata_sub, vae
        
        # free up GPU
        gc.collect()
        torch.cuda.empty_cache()
        print('')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/no6_manual-annotation_atrialCM.html

**Contents:**
- Variables¶
- Read in data¶
- Annotate low quality cells as "unclassified"¶
- Subset and reclustering¶
- Transfer annotation to the original adata¶
- Save¶

--> cluster 4,5,8,10 has lower total counts and smaller cell area --> annotate as "unclassified"

--> CXCL12 expression in SAN-PC?? --> cluster 0,10,15,12,17 are likely to be "doublets" (high expression of other cell type markers, such as POSTN, KDR)

**Examples:**

Example 1 (python):
```python
import matplotlib.pyplot as plt
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

import scanpy.external as sce
```

Example 2 (python):
```python
import session_info
session_info.show()
```

Example 3 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/session_info/main.py:213: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead.
  mod_version = _find_version(mod.__version__)
```

Example 4 (python):
```python
-----
matplotlib          3.10.1
numpy               2.1.3
pandas              2.2.3
scanpy              1.11.1
seaborn             0.13.2
session_info        v1.0.1
-----
```

Example 5 (python):
```python
Cython              3.1.1
PIL                 11.1.0
anndata             0.11.4
asciitree           NA
asttokens           NA
charset_normalizer  3.4.1
cloudpickle         3.1.1
comm                0.2.2
cycler              0.12.1
cython              3.1.1
cython_runtime      NA
dask                2024.11.2
dateutil            2.9.0.post0
debugpy             1.8.13
decorator           5.2.1
exceptiongroup      1.2.2
executing           2.2.0
h5py                3.13.0
igraph              0.11.8
importlib_metadata  NA
ipykernel           6.29.5
jedi                0.19.2
jinja2              3.1.6
joblib              1.4.2
kiwisolver          1.4.8
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.44.0
markupsafe          3.0.2
mpl_toolkits        NA
msgpack             1.1.0
natsort             8.4.0
numba               0.61.0
numcodecs           0.13.1
packaging           24.2
parso               0.8.4
patsy               1.0.1
platformdirs        4.3.7
prompt_toolkit      3.0.50
psutil              7.0.0
pure_eval           0.2.3
pyarrow             19.0.1
pydev_ipython       NA
pydevconsole        NA
pydevd              3.2.3
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.19.1
pyparsing           3.2.3
pytz                2025.2
scipy               1.15.2
six                 1.17.0
sklearn             1.5.2
stack_data          0.6.3
statsmodels         0.14.4
tblib               3.1.0
texttable           1.7.0
threadpoolctl       3.6.0
tlz                 1.0.0
toolz               1.0.0
tornado             6.4.2
traitlets           5.14.3
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.2
zarr                2.18.3
zipp                NA
zmq                 26.3.0
zoneinfo            NA
```

Example 6 (unknown):
```unknown
-----
IPython             8.34.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Linux-4.18.0-553.53.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2025-06-09 20:35
```

Example 7 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/home/kk837/rfs/rfs-teichlab-nfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.set_figure_params(dpi=80)
```

Example 9 (python):
```python
adata_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets'
sample_id = 'C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat'
celltype = 'AtrialCardiomyocytes'
```

Example 10 (unknown):
```unknown
# figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk/Aug2024'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 11 (unknown):
```unknown
latent_space = 'pca_harmony'
```

Example 12 (python):
```python
# read in
adata = sc.read_h5ad(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
adata
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 47076 × 5000
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'leiden_0.2', 'leiden_0.4', 'leiden_0.6', 'leiden_1'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 14 (python):
```python
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
array([3.5825472, 3.5825472, 3.5825472, 3.5825472, 3.5825472],
      dtype=float32)
```

Example 16 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['total_counts','n_genes_by_counts','cell_area','tissue_block_id'],
                    wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 17 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=['multi_celltypes_coarse',"conf_score_midmod2fine","celltypist_midmod2fine",],
                    wspace=0.2,cmap='RdPu',vmax='p100')
resolutions_list = [0.2,0.4,0.6,1]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                    color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                    wspace=0.2)
```

Example 18 (python):
```python
%%time
# leiden clustering
resolutions_list = [# 0.2,0.4,0.6,1, # already done
                    1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata,neighbors_key=latent_space,
                     resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 19 (unknown):
```unknown
<timed exec>:5: FutureWarning: In the future, the default backend for leiden will be igraph instead of leidenalg.

 To achieve the future defaults please pass: flavor="igraph" and n_iterations=2.  directed must also be False to work with igraph's implementation.
```

Example 20 (unknown):
```unknown
CPU times: user 50.2 s, sys: 400 ms, total: 50.6 s
Wall time: 50.7 s
```

Example 21 (python):
```python
# check marker expressions
genes = ['TBX3','TBX18','SHOX2','HCN1','HCN4','CACNA1D', 'GJA1','VSNL1',# SANPC
         'GREB1L','GNG11','NRXN3','RSPO3', # AVNPC
         'PITX2','KCNMB2','PCDH7','RYR3','MBP', # aCM_left
         'NTM','ROR1','KIF26B','PLCL1','ANGPT1', # aCM_right
         'NKX2-5','MKI67','TOP2A'
        ]
genes = [x for x in genes if x in adata.var_names]
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 22 (unknown):
```unknown
resolution_sel = 1.5
```

Example 23 (python):
```python
sc.pl.violin(adata,keys=['total_counts','cell_area'],groupby=f'leiden_{str(resolution_sel)}')
```

Example 24 (python):
```python
# annotate
adata.obs['tmp_annotation'] = adata.obs[f'leiden_{str(resolution_sel)}'].copy()
adata.obs.replace({'tmp_annotation':{
    '0':'AtrialCardiomyocytes',
    '1':'AtrialCardiomyocytes',
    '2':'AtrialCardiomyocytes',
    '3':'AtrialCardiomyocytes',
    '4':'unclassified',
    '5':'unclassified',
    '6':'AtrialCardiomyocytes',
    '7':'AtrialCardiomyocytes',
    '8':'unclassified',
    '9':'AtrialCardiomyocytes',
    '10':'unclassified',
    '11':'AtrialCardiomyocytes',
    '12':'AtrialCardiomyocytes',
    '13':'AtrialCardiomyocytes',
    '14':'AtrialCardiomyocytes',
    '15':'AtrialCardiomyocytes',
}},inplace=True)
adata.obs['tmp_annotation'].value_counts()
```

Example 25 (python):
```python
/tmp/ipykernel_60220/1768720550.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({'tmp_annotation':{
```

Example 26 (unknown):
```unknown
tmp_annotation
AtrialCardiomyocytes    33947
unclassified            13129
Name: count, dtype: int64
```

Example 27 (python):
```python
sc.pl.embedding(adata, basis=f"X_umap_{latent_space}",
                color='tmp_annotation',
               ncols=5, wspace=0.2)
```

Example 28 (python):
```python
adata_sub = adata[adata.obs['tmp_annotation']=='AtrialCardiomyocytes']
```

Example 29 (python):
```python
# drop leiden clustering results
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    adata_sub.obs.drop(f'leiden_{str(resolution)}',axis=1,inplace=True)
adata_sub
```

Example 30 (unknown):
```unknown
AnnData object with n_obs × n_vars = 33947 × 5000
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'tmp_annotation'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1', 'n_cells', 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'celltypist_midmod2fine_colors', 'dendrogram_pca_harmony_leiden_1.0', 'hvg', 'leiden_0.2', 'leiden_0.2_colors', 'leiden_0.4', 'leiden_0.4_colors', 'leiden_0.6', 'leiden_0.6_colors', 'leiden_1', 'leiden_1_colors', 'log1p', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap', 'leiden_1.2', 'leiden_1.5', 'leiden_2', 'leiden_1.2_colors', 'leiden_1.5_colors', 'leiden_2_colors', 'tmp_annotation_colors'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 31 (python):
```python
# HVGs
# sc.pp.highly_variable_genes(adata_sub, flavor='seurat', min_mean=0.0125, max_mean=3, min_disp=0.5)
# print(f'number of hvgs: {sum(adata_sub.var.highly_variable)}')
# PCA
sc.tl.pca(adata_sub, use_highly_variable=False)
# harmony integration
sce.pp.harmony_integrate(adata_sub, 'tissue_block_id', basis='X_pca', adjusted_basis='X_pca_harmony')
# create neighbour graph
latent_space = 'pca_harmony'
sc.pp.neighbors(adata_sub,n_neighbors=15,use_rep=f"X_{latent_space}",key_added=latent_space)
# visualisation with umap
sc.tl.umap(adata_sub,min_dist=0.5,neighbors_key=latent_space)
adata_sub.obsm[f"X_umap_{latent_space}"]=adata_sub.obsm["X_umap"]
del adata_sub.obsm["X_umap"]
```

Example 32 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_pca/__init__.py:438: FutureWarning: Argument `use_highly_variable` is deprecated, consider using the mask argument. Use_highly_variable=True can be called through mask_var="highly_variable". Use_highly_variable=False can be called through mask_var=None
  warn(msg, FutureWarning)
2025-06-09 20:36:42,658 - harmonypy - INFO - Computing initial centroids with sklearn.KMeans...
2025-06-09 20:36:46,050 - harmonypy - INFO - sklearn.KMeans initialization complete.
2025-06-09 20:36:46,145 - harmonypy - INFO - Iteration 1 of 10
2025-06-09 20:36:51,846 - harmonypy - INFO - Iteration 2 of 10
2025-06-09 20:36:57,428 - harmonypy - INFO - Converged after 2 iterations
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 33 (python):
```python
%%time
# reclustering
# leiden clustering
resolutions_list = [0.2,0.4,0.6,1, 1.2,1.5,2]
for resolution in resolutions_list:
    sc.tl.leiden(adata_sub,neighbors_key=latent_space,
                 resolution=resolution,key_added=f'leiden_{str(resolution)}',n_iterations=2)
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=[f'leiden_{str(resolution)}' for resolution in resolutions_list],
                wspace=0.3)
```

Example 34 (unknown):
```unknown
CPU times: user 55.8 s, sys: 561 ms, total: 56.4 s
Wall time: 56.5 s
```

Example 35 (python):
```python
genes = ['TBX3','TBX18','SHOX2','HCN1','HCN4','CACNA1D', 'GJA1','VSNL1',# SANPC
         'GREB1L','GNG11','NRXN3','RSPO3', # AVNPC
         'PITX2','KCNMB2','PCDH7','RYR3','MBP', # aCM_left
         'NTM','ROR1','KIF26B','PLCL1','ANGPT1', # aCM_right
         'NKX2-5','MKI67','TOP2A'
        ]
genes = [x for x in genes if x in adata_sub.var_names]
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=genes,
               ncols=5, wspace=0.2,cmap='RdPu',vmax='p100')
```

Example 36 (unknown):
```unknown
sub_resolution_sel = 2
```

Example 37 (python):
```python
genes = ['TTN', 'TNNT2','MYH6', # generic CM marker
        'MYH7', 'MYL2', 'FHL2', # vCN
            'NPPA', 'MYL7', 'MYL4', #aCM
    'TBX3','TBX18','SHOX2','HCN1','HCN4','CACNA1D', 'GJA1','VSNL1',# SANPC
         'GREB1L','GNG11','NRXN3','RSPO3', # AVNPC
         'PITX2','KCNMB2','PCDH7','RYR3','MBP', # aCM_left
         'NTM','ROR1','KIF26B','PLCL1','ANGPT1', # aCM_right
         'MKI67','TOP2A','NKX2-5'
        ]
genes = [x for x in genes if x in adata.var_names]

sc.tl.dendrogram(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.pl.dotplot(adata_sub,
              var_names=genes,
              groupby=f'leiden_{str(sub_resolution_sel)}',
              standard_scale='var',
              dendrogram=True
             )
```

Example 38 (python):
```python
# DEG analysis
print(adata_sub.X.data[:5])
adata_sub.uns['log1p']['base']=None
sc.tl.rank_genes_groups(adata_sub,groupby=f'leiden_{str(sub_resolution_sel)}')
sc.tl.dendrogram(adata_sub, groupby=f'leiden_{str(sub_resolution_sel)}')
dp=sc.pl.rank_genes_groups_dotplot(adata_sub, dendrogram=True, standard_scale='var', return_fig=True)
dp.add_totals().show()
```

Example 39 (unknown):
```unknown
[2.4920871 2.4920871 3.1429856 2.4920871 4.3644395]
```

Example 40 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:458: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "names"] = self.var_names[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:460: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "scores"] = scores[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:463: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals"] = pvals[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:473: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "pvals_adj"] = pvals_adj[global_indices]
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/tools/_rank_genes_groups.py:484: PerformanceWarning: DataFrame is highly fragmented.  This is usually the result of calling `frame.insert` many times, which has poor performance.  Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
  self.stats[group_name, "logfoldchanges"] = np.log2(
```

Example 41 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'leiden_{str(sub_resolution_sel)}',legend_loc='on data',
                wspace=0.3)
```

Example 42 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color=f'multi_celltypes_coarse',legend_loc='on data',
                wspace=0.3)
```

Example 43 (python):
```python
# annotate
adata_sub.obs['fine_grain_manual'] = adata_sub.obs[f'leiden_{str(sub_resolution_sel)}'].copy()
adata_sub.obs.replace({'fine_grain_manual':{
    '0':'AtrialCardiomyocytes_DoubletWithFB',
    '1':'AtrialCardiomyocytesRight',
    '2':'AtrialCardiomyocytesLeft',
    '3':'AtrialCardiomyocytesRight',
    '4':'AtrioventricularNodePacemakerCells',
    '5':'AtrialCardiomyocytesRight',
    '6':'AtrialCardiomyocytesLeft',
    '7':'AtrialCardiomyocytesLeft',
    '8':'AtrialCardiomyocytesCycling',
    '9':'AtrialCardiomyocytesCycling',
    '10':'AtrialCardiomyocytes_DoubletWithEC',
    '11':'AtrialCardiomyocytesCycling',
    '12':'AtrialCardiomyocytes_DoubletWithFB',
    '13':'AtrialCardiomyocytesCycling',
    '14':'AtrialCardiomyocytesRight',
    '15':'AtrialCardiomyocytes_DoubletWithFB',
    '16':'AtrialCardiomyocytesCycling',
    '17':'AtrialCardiomyocytes_DoubletWithEC',
    '18':'AtrialCardiomyocytesRight',
    '19':'SinoatrialNodePacemakerCells',
    '20':'AtrialCardiomyocytesRight',
    '21':'AtrialCardiomyocytesLeft',
    '22':'AtrialCardiomyocytesLeft',
}},inplace=True)
adata_sub.obs['fine_grain_manual'].value_counts()
```

Example 44 (python):
```python
/tmp/ipykernel_60220/1879809394.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_sub.obs.replace({'fine_grain_manual':{
```

Example 45 (unknown):
```unknown
fine_grain_manual
AtrialCardiomyocytesRight             9633
AtrialCardiomyocytesLeft              7206
AtrialCardiomyocytesCycling           7112
AtrialCardiomyocytes_DoubletWithFB    5201
AtrialCardiomyocytes_DoubletWithEC    2232
AtrioventricularNodePacemakerCells    2085
SinoatrialNodePacemakerCells           478
Name: count, dtype: int64
```

Example 46 (python):
```python
sc.pl.embedding(adata_sub, basis=f"X_umap_{latent_space}",
                color='fine_grain_manual',
                wspace=0.3)
```

Example 47 (python):
```python
adata.obs['fine_grain_manual'] = 'unclassified'
adata.obs.loc[adata_sub.obs_names,'fine_grain_manual'] = adata_sub.obs['fine_grain_manual']
```

Example 48 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
                  spot_size=30,vmax='p100')
```

Example 49 (python):
```python
/tmp/ipykernel_60220/681652047.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 50 (python):
```python
/tmp/ipykernel_60220/681652047.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],# groups='SinoatrialNodePacemakerCells',
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 51 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],groups='SinoatrialNodePacemakerCells',
                  spot_size=60,vmax='p100')
```

Example 52 (python):
```python
/tmp/ipykernel_60220/1370592205.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='SinoatrialNodePacemakerCells',
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 53 (python):
```python
/tmp/ipykernel_60220/1370592205.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],groups='SinoatrialNodePacemakerCells',
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 54 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],
                  groups=['AtrialCardiomyocytesRight'],
                  spot_size=60,vmax='p100')
```

Example 55 (python):
```python
/tmp/ipykernel_60220/2612643899.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 56 (python):
```python
/tmp/ipykernel_60220/2612643899.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 57 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['fine_grain_manual'],
                  groups=['AtrialCardiomyocytesLeft'],
                  spot_size=60,vmax='p100')
```

Example 58 (python):
```python
/tmp/ipykernel_60220/3050971786.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 59 (python):
```python
/tmp/ipykernel_60220/3050971786.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['fine_grain_manual'],
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 60 (python):
```python
for tissue_id in ['C194-HEA-0-FFPE-1', 'Hst45-HEA-0-FFPE-1']:
    slide = adata[adata.obs['tissue_block_id']==tissue_id]
    sc.pl.spatial(slide,color=['CXCL12'],cmap='RdPu',
                  spot_size=60,vmax='p100')
```

Example 61 (python):
```python
/tmp/ipykernel_60220/2026526932.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['CXCL12'],cmap='RdPu',
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 62 (python):
```python
/tmp/ipykernel_60220/2026526932.py:3: FutureWarning: Use `squidpy.pl.spatial_scatter` instead.
  sc.pl.spatial(slide,color=['CXCL12'],cmap='RdPu',
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/anndata/_core/anndata.py:1138: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  df[key] = c
```

Example 63 (python):
```python
# save
adata.write(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
print(f'{adata_dir}/{sample_id}_5K_{celltype}_lognorm.h5ad')
```

Example 64 (unknown):
```unknown
/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium/subsets/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_AtrialCardiomyocytes_lognorm.h5ad
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Xenium/no2_integration_and_cell-type-annotation/Xenium5K_corr_with_scnRNAseq.html

**Contents:**
- Import modules¶
- Read in qeury adata¶
- Read in reference adata¶
- Harmonise cell type names¶
- Prepare celltype-by-gene dataframes¶

**Examples:**

Example 1 (python):
```python
import numpy as np
import pandas as pd
import scanpy as sc
import anndata
import os
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 

sc.settings.verbosity = 1  # verbosity: errors (0), warnings (1), info (2), hints (3)
```

Example 2 (python):
```python
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/rfs/project/rfs-iCNyzSAaucw/kk837/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 3 (unknown):
```unknown
figdir = '/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/fetal_ms_figures'
# table_dir = '/nfs/team205/heart/fetal_ms_figures/tables/Aug2024'
```

Example 4 (python):
```python
# read in 
objects_dir = '/home/kk837/rds/rds-teichlab-C9woKbOCf2Y/kk837/Foetal/anndata_objects/Xenium'
path_adata = f'{objects_dir}/C194-HEA-0-FFPE-1_Hst45-HEA-0-FFPE-1_concat_5K_filtered_raw.h5ad'
adata = sc.read_h5ad(path_adata)
adata
```

Example 5 (unknown):
```unknown
AnnData object with n_obs × n_vars = 362277 × 5001
    obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'genomic_control_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'nucleus_count', 'segmentation_method', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_150_genes', 'n_counts', 'n_genes', 'tissue_block_id', 'celltypist_coarse', 'conf_score_coarse', 'celltypist_coarse_fin', 'celltypist_coarse2midmod', 'conf_score_coarse2midmod', 'celltypist_mid_fin', 'celltypist_midmod2fine', 'conf_score_midmod2fine', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_3.0', 'multi_celltypes_coarse', 'fine_grain_12Jun2025'
    var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts-0', 'mean_counts-0', 'log1p_mean_counts-0', 'pct_dropout_by_counts-0', 'total_counts-0', 'log1p_total_counts-0', 'n_cells_by_counts-1', 'mean_counts-1', 'log1p_mean_counts-1', 'pct_dropout_by_counts-1', 'total_counts-1', 'log1p_total_counts-1'
    uns: 'celltypist_coarse2midmod_colors', 'celltypist_coarse_colors', 'celltypist_mid_fin_colors', 'dendrogram_pca_harmony_leiden_1.0', 'fine_grain_12Jun2025_colors', 'multi_celltypes_coarse_colors', 'pca', 'pca_harmony', 'pca_harmony_leiden_0.2', 'pca_harmony_leiden_0.2_colors', 'pca_harmony_leiden_0.3', 'pca_harmony_leiden_0.3_colors', 'pca_harmony_leiden_0.4', 'pca_harmony_leiden_0.4_colors', 'pca_harmony_leiden_0.5', 'pca_harmony_leiden_0.5_colors', 'pca_harmony_leiden_0.8', 'pca_harmony_leiden_0.8_colors', 'pca_harmony_leiden_1.0', 'pca_harmony_leiden_1.0_colors', 'pca_harmony_leiden_1.5', 'pca_harmony_leiden_1.5_colors', 'pca_harmony_leiden_2.0', 'pca_harmony_leiden_2.0_colors', 'pca_harmony_leiden_3.0', 'pca_harmony_leiden_3.0_colors', 'tissue_block_id_colors', 'umap'
    obsm: 'X_pca', 'X_pca_harmony', 'X_umap_pca_harmony', 'spatial'
    varm: 'PCs'
    obsp: 'pca_harmony_connectivities', 'pca_harmony_distances'
```

Example 6 (unknown):
```unknown
celltype_col = 'fine_grain_12Jun2025'
```

Example 7 (python):
```python
# log-normalise the count
print(adata.X.data[:5])
sc.pp.filter_genes(adata, min_cells=3)
sc.pp.normalize_total(adata,target_sum=1e4)
sc.pp.log1p(adata)
print(adata.X.data[:5])
```

Example 8 (unknown):
```unknown
[5. 1. 1. 2. 2.]
[4.2093534 2.6576407 2.6576407 3.3151019 3.3151019]
```

Example 9 (python):
```python
# update cell type name for plotting
df = pd.read_csv('/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/finegrain_name_mapping.csv')
celltype_mapping = df.set_index('Full_name')['Short_name_finalised'].to_dict()
adata.obs.replace({celltype_col:celltype_mapping},inplace=True)
```

Example 10 (python):
```python
/tmp/ipykernel_3438200/966943319.py:4: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata.obs.replace({celltype_col:celltype_mapping},inplace=True)
```

Example 11 (python):
```python
# remove doublets and non-cardiac cells
mask = [x in celltype_mapping.values() for x in adata.obs[celltype_col]]
adata = adata[mask]
```

Example 12 (python):
```python
adata_ref = sc.read_h5ad('/rfs/project/rfs-iCNyzSAaucw/kk837/data_objects/Foetal/RNA/Feb28ObjectRaw_finegrain_updated.h5ad')
adata_ref
```

Example 13 (unknown):
```unknown
AnnData object with n_obs × n_vars = 297473 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 14 (python):
```python
# subset genes and log-normalise
adata_ref = adata_ref[:,adata.var_names]
print(adata_ref.X.data[:5])
sc.pp.normalize_total(adata_ref,target_sum=1e4)
sc.pp.log1p(adata_ref)
print(adata_ref.X.data[:5])
```

Example 15 (unknown):
```unknown
[1. 1. 3. 4. 1.]
```

Example 16 (python):
```python
/home/kk837/.conda/envs/generic_env/lib/python3.10/site-packages/scanpy/preprocessing/_normalization.py:216: UserWarning: Received a view of an AnnData. Making a copy.
  view_to_actual(adata)
```

Example 17 (unknown):
```unknown
[0.44856235 0.44856235 0.9925765  1.1830258  0.44856235]
```

Example 18 (python):
```python
# update cell type name
df = pd.read_csv('/rfs/project/rfs-iCNyzSAaucw/kk837/notebooks/Foetal/finegrain_name_mapping.csv')
celltype_mapping = df.set_index('Full_name')['Short_name_finalised'].to_dict()
adata_ref.obs.replace({'fine_grain':celltype_mapping},inplace=True)
```

Example 19 (python):
```python
/tmp/ipykernel_3438200/3465093248.py:4: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.
  adata_ref.obs.replace({'fine_grain':celltype_mapping},inplace=True)
```

Example 20 (python):
```python
celltype_mapping_2 = {
    'BMS4':'B',
    'CorAdvFB':'FB',
    'GVAdvFB':'FB',
    'MonoMPO':'Mono',
    'MyoFB':'FB',
    'MyoFb':'FB',
     'ProB':'B',
    'SubEpiFb':'FB',
    'vCMCL':'vCM',
    'vCMCR':'vCM',
    'vCMTL':'vCM',
    'vCMTR':'vCM',
    'FBCOL2A1':'FB',
    'GVSMCP':'GVSMC',
    'GVSMCT':'GVSMC',
    'SANPCHd':'SANPC',
     'SANPCHn':'SANPC',
     'SANPCT':'SANPC',
    'CorCapECN':'CorCapEC',
    'DCMat':'DC',
 'DCT1':'DC',
}
adata.obs[celltype_col] = [celltype_mapping_2[x] if x in celltype_mapping_2.keys() else x for x in adata.obs[celltype_col]]
adata_ref.obs['fine_grain'] = [celltype_mapping_2[x] if x in celltype_mapping_2.keys() else x for x in adata_ref.obs['fine_grain']]
```

Example 21 (python):
```python
/tmp/ipykernel_3438200/752604715.py:24: ImplicitModificationWarning: Trying to modify attribute `.obs` of view, initializing view as actual.
  adata.obs[celltype_col] = [celltype_mapping_2[x] if x in celltype_mapping_2.keys() else x for x in adata.obs[celltype_col]]
```

Example 22 (python):
```python
adata_agg = sc.get.aggregate(adata, by=celltype_col, func=["mean"])
adata_agg.X = adata_agg.layers['mean']
query_df = adata_agg.to_df()
print(f'original query df, shape: {query_df.shape}')

adata_ref_agg = sc.get.aggregate(adata_ref, by='fine_grain', func=["mean"])
adata_ref_agg.X = adata_ref_agg.layers['mean']
ref_df = adata_ref_agg.to_df()
print(f'original ref_df, shape: {ref_df.shape}')

shared_celltypes = list(set(query_df.index).intersection(ref_df.index))
query_df = query_df.loc[shared_celltypes].T
ref_df = ref_df.loc[shared_celltypes].T
print(f'post-subset query df, shape: {query_df.shape}')
print(f'post-subset ref_df, shape: {ref_df.shape}')
```

Example 23 (unknown):
```unknown
original query df, shape: (51, 5001)
original ref_df, shape: (52, 5001)
post-subset query df, shape: (5001, 42)
post-subset ref_df, shape: (5001, 42)
```

Example 24 (python):
```python
%%time
figsize = (10,10)
cmap = 'inferno'
corr, pval = utils.df_pearson_corr_with_p_vectorized(query_df, ref_df, p_adjust='fdr_bh')

# draw the initial clustermap (for ordering only)
cg = sns.clustermap(
    corr,
    cmap=cmap,
    # center=0,
    metric='euclidean',
    method='average',
    figsize=figsize
)

# 4) extract the leaf order and reindex both matrices
order = cg.dendrogram_row.reordered_ind
labels = list(corr.index[order])

corr_ord = corr.loc[labels, labels]
pval_ord = pval.loc[labels, labels]

# 5) replot as a heatmap and annotate significance
fig, ax = plt.subplots(figsize=figsize)
sns.heatmap(
    corr_ord,
    cmap=cmap,
    # center=0,
    square=True,
    cbar_kws={'label': 'Pearson r'},
    ax=ax
)

'''
# add asterisks for p < 0.01
n = corr_ord.shape[0]
for i in range(n):
    for j in range(n):
        if pval_ord.iat[i, j] < 0.0001:
            ax.text(j + 0.5, i + 0.5, '*',
                    ha='center', va='center',
                    fontsize=10)
'''

ax.set_xticklabels(labels, rotation=90)
ax.set_xlabel('scnRNA-seq')
ax.set_yticklabels(labels, rotation=0)
ax.set_ylabel('Xenium5K')
plt.tight_layout()
plt.savefig(f'{figdir}/Xenium5K-vs-scnRNAseq_celltype-gex-corr.pdf', bbox_inches="tight",dpi=300)
plt.show()
```

Example 25 (unknown):
```unknown
CPU times: user 2.05 s, sys: 252 ms, total: 2.3 s
Wall time: 2.54 s
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig5_Trisomy21/no02_t21_post-scVI_cleanup.html

**Contents:**
- Import modules¶
- Read in data¶
- Filter and log-normalise¶
- CellTypist prediction¶
- Select cells to remove¶
- Remove from the raw data¶
- recalculate UMAP, etc¶
- Modify obs¶
- CellTypist prediction for fine-grained labels (run per coarse-grained)¶

"Pericardium" region is not represented in "Heart" and other region samples. In addition, "Pericardium" sample is coming from one donor "Pericardium" will be removed at downstream analysis

**Examples:**

Example 1 (python):
```python
import numpy as np
import numpy.random as random
import pandas as pd
import scanpy as sc
import matplotlib.pyplot as plt
import seaborn as sns
import celltypist
```

Example 2 (python):
```python
/nfs/team205/kk18/miniconda3/envs/vitro/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 3 (python):
```python
import session_info
session_info.show()
```

Example 4 (python):
```python
-----
celltypist          1.6.2
matplotlib          3.7.2
numpy               1.22.4
pandas              1.5.3
scanpy              1.9.3
seaborn             0.12.2
session_info        1.0.0
-----
```

Example 5 (python):
```python
PIL                         10.0.0
anndata                     0.9.2
anyio                       NA
arrow                       1.2.3
asciitree                   NA
asttokens                   NA
attr                        23.1.0
attrs                       23.1.0
babel                       2.12.1
backcall                    0.2.0
brotli                      1.0.9
certifi                     2023.11.17
cffi                        1.15.1
charset_normalizer          3.2.0
cloudpickle                 3.0.0
colorama                    0.4.6
comm                        0.1.4
cycler                      0.10.0
cython_runtime              NA
dask                        2023.5.0
dateutil                    2.8.2
debugpy                     1.6.8
decorator                   5.1.1
defusedxml                  0.7.1
executing                   1.2.0
fasteners                   0.19
fastjsonschema              NA
fqdn                        NA
h5py                        3.9.0
idna                        3.4
igraph                      0.10.6
importlib_metadata          NA
importlib_resources         NA
ipykernel                   6.25.1
isoduration                 NA
jedi                        0.19.0
jinja2                      3.1.2
joblib                      1.3.2
json5                       NA
jsonpointer                 2.0
jsonschema                  4.19.0
jsonschema_specifications   NA
jupyter_events              0.7.0
jupyter_server              2.7.1
jupyterlab_server           2.24.0
kiwisolver                  1.4.5
leidenalg                   0.10.1
llvmlite                    0.38.1
markupsafe                  2.1.3
mpl_toolkits                NA
natsort                     8.4.0
nbformat                    5.9.2
numba                       0.55.2
numcodecs                   0.12.1
opt_einsum                  v3.3.0
overrides                   NA
packaging                   23.1
parso                       0.8.3
patsy                       0.5.3
pexpect                     4.8.0
pickleshare                 0.7.5
pkg_resources               NA
plotly                      5.16.1
prometheus_client           NA
prompt_toolkit              3.0.39
psutil                      5.9.5
ptyprocess                  0.7.0
pure_eval                   0.2.2
pyarrow                     15.0.2
pydev_ipython               NA
pydevconsole                NA
pydevd                      2.9.5
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pygments                    2.16.1
pyparsing                   3.0.9
pythonjsonlogger            NA
pytz                        2023.3
referencing                 NA
requests                    2.31.0
rfc3339_validator           0.1.4
rfc3986_validator           0.1.1
rpds                        NA
ruamel                      NA
scipy                       1.10.1
send2trash                  NA
six                         1.16.0
sklearn                     1.3.0
sniffio                     1.3.0
socks                       1.7.1
sphinxcontrib               NA
stack_data                  0.6.2
statsmodels                 0.14.0
texttable                   1.6.7
threadpoolctl               3.2.0
tlz                         0.12.1
toolz                       0.12.1
torch                       1.13.1+cu117
tornado                     6.3.3
tqdm                        4.66.1
traitlets                   5.9.0
typing_extensions           NA
uri_template                NA
urllib3                     2.0.4
wcwidth                     0.2.6
webcolors                   1.13
websocket                   1.6.2
yaml                        6.0.1
zarr                        2.16.1
zipp                        NA
zmq                         25.1.1
zstandard                   0.19.0
```

Example 6 (unknown):
```unknown
-----
IPython             8.12.0
jupyter_client      8.3.0
jupyter_core        4.12.0
jupyterlab          4.0.5
notebook            7.0.2
-----
Python 3.8.17 (default, Jul  5 2023, 21:04:15) [GCC 11.2.0]
Linux-5.15.0-113-generic-x86_64-with-glibc2.17
-----
Session information updated at 2024-08-01 08:21
```

Example 7 (python):
```python
# import own function
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/nfs/team205/kk18/function/python/utils.py")
utils = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = utils
spec.loader.exec_module(utils)
```

Example 8 (python):
```python
sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=120)
```

Example 9 (python):
```python
adata = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_July2024.h5ad')
adata
```

Example 10 (unknown):
```unknown
AnnData object with n_obs × n_vars = 121452 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1'
    var: 'gene_name', 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts'
    uns: 'age_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 11 (python):
```python
adata.var['gene_id'] = adata.var_names.copy()
adata.var.set_index('gene_name',inplace=True)
adata.var_names = adata.var_names.astype('str')
adata.var_names_make_unique()
```

Example 12 (python):
```python
sc.pp.filter_genes(adata, min_cells=3)
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
```

Example 13 (unknown):
```unknown
filtered out 3535 genes that are detected in less than 3 cells
normalizing counts per cell
    finished (0:00:01)
```

Example 14 (python):
```python
print(adata.shape)
adata.X.data[:5]
```

Example 15 (unknown):
```unknown
(121452, 33066)
```

Example 16 (unknown):
```unknown
array([0.0534004 , 0.10409318, 0.19836526, 0.0534004 , 0.15233971],
      dtype=float32)
```

Example 17 (python):
```python
# coarse-grained
predictions = celltypist.annotate(adata, 
                                  model = '/nfs/team205/kk18/notebooks/Foetal/VisiumHD/mpp0p3/celltypist_models/from_foetal_portal/foetal_heart_coarse.pkl', 
                                  majority_voting = False)

# add to anndata
adata = predictions.to_adata(insert_labels = True, insert_conf = True)
adata.obs.rename(columns={'predicted_labels':'celltypist_coarse',
                              'conf_score':'conf_score_coarse'
                             },inplace=True)
adata.obs.head()
```

Example 18 (unknown):
```unknown
🔬 Input data has 121452 cells and 33066 genes
🔗 Matching reference genes in the model
🧬 29480 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
```

Example 19 (python):
```python
sc.pl.umap(adata, color=['celltypist_coarse','conf_score_coarse','leiden_scVI_1'], size=1, legend_fontsize=6, wspace=0.2)
```

Example 20 (python):
```python
# umap per celltype to highlight
group_col = 'region'
groups_to_plot = ['Heart',
                  'Great vessels', 
                 'Left atria',
                 'Left ventricle',
                 'Pericardial sac + RA + LA + IAS',
                 'Right ventricle',
                  'Pericardium',
                 ]

plt.rcParams['axes.grid'] = False
fig,axs=plt.subplots(nrows=2,ncols=4,figsize=(15,7))
# Flatten the axs array for easier iteration in case of multiple rows and columns
axs_flat = axs.flatten()

for i,grp in enumerate(groups_to_plot):
    sc.pl.umap(adata, color=[group_col], groups=grp, 
               size=10, frameon=False,
               show=False, ax=axs_flat[i], legend_loc=None, legend_fontsize=5,
               title=grp
              )
# Turn off any remaining subplots
for j in range(len(groups_to_plot), len(axs_flat)):
    fig.delaxes(axs_flat[j])

# fig.suptitle('Main Title for the Figure')
fig.tight_layout()
```

Example 21 (python):
```python
# mean condidence score
group_col = 'leiden_scVI_1'
conf_score_col = 'conf_score_coarse'
df = adata.obs[[group_col,conf_score_col]].groupby(group_col).mean()
df.sort_values(conf_score_col,ascending=False)
```

Example 22 (python):
```python
# cell type marker expression
markers = {
    'vCM': ['MYH7', 'MYL2', 'FHL2'],
    'aCM': ['NPPA', 'MYL7', 'MYL4'],
    'FB': ['DCN', 'GCN', 'PDGFRA'],
    'EC': ['VWF', 'PECAM1', 'CDH5'],
    'Peri': ['RGS5', 'ABCC9', 'KCNJ8'],
    'SMC': ['MYH11', 'TAGLN', 'ACTA2'],
    'Meso': ['MSLN', 'WT1', 'BNC1'],
    'Neuro': ['PLP1', 'NRXN1', 'NRXN3'],
    'Adipo': ['GPAM', 'FASN', 'LEP'],
    'Myelo': ['CD14', 'C1QA', 'CD68','LYVE1','TIMD4'],
    'Lymph': ['CD8A', 'IL7R', 'CD40LG'],
    'B': ['CD19','SDC1','IGHG1','IGHA1'],
    'Mast': ['KIT', 'CPA3'],
}

for key in markers.keys():
    markers[key]=[x for x in markers[key] if x in adata.var_names]

sc.tl.dendrogram(adata, groupby=group_col)
sc.pl.dotplot(adata,
              markers, 
              groupby=group_col,
              dendrogram=True,
              standard_scale="var",
              color_map="Reds",
              # swap_axes=True,
             )
```

Example 23 (unknown):
```unknown
using 'X_pca' with n_pcs = 50
Storing dendrogram info using `.uns['dendrogram_leiden_scVI_1']`
WARNING: Groups are not reordered because the `groupby` categories and the `var_group_labels` are different.
categories: 0, 1, 2, etc.
var_group_labels: vCM, aCM, FB, etc.
```

Example 24 (python):
```python
# sangerID proportion
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["region"])
# Normalize each row to sum to 1 (i.e., to get fractions)
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)

# Plotting the stacked bar chart
ax = crosstab_normalized.plot(kind='bar',stacked=True,figsize=(10, 4),legend=False)

# Adding labels and title
plt.ylabel('Fraction')
plt.title('Normalized Stacked Bar Chart')
plt.legend(bbox_to_anchor=(0.95, 0.5, 0.5, 0.5))

# Show the plot
plt.show()
```

Example 25 (python):
```python
# donor proportion
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["donor"])
# Normalize each row to sum to 1 (i.e., to get fractions)
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)

# Plotting the stacked bar chart
ax = crosstab_normalized.plot(kind='bar',stacked=True,figsize=(10, 4),legend=False)

# Adding labels and title
plt.ylabel('Fraction')
plt.title('Normalized Stacked Bar Chart')
plt.legend(bbox_to_anchor=(0.8, 0., 0.5, 0.5))

# Show the plot
plt.show()
```

Example 26 (python):
```python
# sangerID proportion
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["sangerID"])
# Normalize each row to sum to 1 (i.e., to get fractions)
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)

# Plotting the stacked bar chart
ax = crosstab_normalized.plot(kind='bar',stacked=True,figsize=(10, 4),legend=False)

# Adding labels and title
plt.ylabel('Fraction')
plt.title('Normalized Stacked Bar Chart')
plt.legend(bbox_to_anchor=(0.8, 0.5, 0.5, 0.5))

# Show the plot
plt.show()
```

Example 27 (python):
```python
sc.settings.set_figure_params(dpi=120)
sc.pl.umap(adata, color=['leiden_scVI_1'], size=1, legend_fontsize=6, wspace=0.2, legend_loc='on data')
```

Example 28 (python):
```python
conf_score_thresh = 0.6

# identify single-sample clusters
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["sangerID"])
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)
res = crosstab_normalized.max(axis=1)
single_sample_clusters = list(res.index[res>0.9])
print(f'single_sample_clusters: {single_sample_clusters}')

# identify pericardium clusters
crosstab=pd.crosstab(adata.obs[group_col],adata.obs["region"])
crosstab_normalized = crosstab.div(crosstab.sum(axis=1), axis=0)
res = crosstab_normalized['Pericardium']
pericardium_clusters = list(res.index[res>0.9])
print(f'pericardium_clusters: {pericardium_clusters}')

single_butnot_peri_clusters = list(set(single_sample_clusters)-set(pericardium_clusters))
print(f'single_butnot_peri_clusters: {single_butnot_peri_clusters}')

mask1 = adata.obs[group_col].isin(['4','19'])
mask2 = adata.obs[conf_score_col] < conf_score_thresh
mask3 = adata.obs[group_col].isin(single_butnot_peri_clusters)
adata.obs['cells_to_remove'] = 'No'
adata.obs.loc[adata.obs_names[mask1|mask2|mask3],'cells_to_remove'] = 'Yes'
sc.pl.umap(adata, color=['cells_to_remove'], size=1, legend_fontsize=6, wspace=0.2)
```

Example 29 (unknown):
```unknown
... storing 'cells_to_remove' as categorical
```

Example 30 (unknown):
```unknown
single_sample_clusters: ['4', '12', '14', '17', '19', '21', '27', '30', '36']
pericardium_clusters: ['12', '14', '17', '19', '21', '27', '30']
single_butnot_peri_clusters: ['36', '4']
```

Example 31 (python):
```python
adata_raw = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_July2024.h5ad')
adata_raw
```

Example 32 (unknown):
```unknown
AnnData object with n_obs × n_vars = 121452 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1'
    var: 'gene_name', 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts'
    uns: 'age_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 33 (python):
```python
adata_raw.var['gene_id'] = adata_raw.var_names.copy()
adata_raw.var.set_index('gene_name',inplace=True)
adata_raw.var_names = adata_raw.var_names.astype('str')
adata_raw.var_names_make_unique()
```

Example 34 (python):
```python
# add prediction results, etc
adata_raw.obs[['celltypist_coarse','conf_score_coarse','cells_to_remove']] = adata[adata_raw.obs_names].obs[['celltypist_coarse','conf_score_coarse','cells_to_remove']].copy()
```

Example 35 (python):
```python
# remove
adata_raw = adata_raw[adata_raw.obs['cells_to_remove']=='No']
sc.pl.umap(adata_raw, color=['cells_to_remove'], size=1, legend_fontsize=6, wspace=0.2)
```

Example 36 (python):
```python
# save
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
```

Example 37 (python):
```python
%%time
sc.pp.neighbors(adata_raw, use_rep="X_scVI")
sc.tl.umap(adata_raw, min_dist=0.2)
```

Example 38 (python):
```python
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:37)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:02:11)
CPU times: user 2min 46s, sys: 733 ms, total: 2min 47s
Wall time: 2min 49s
```

Example 39 (python):
```python
sc.pl.umap(adata_raw, color=['celltypist_coarse'], frameon=False)
```

Example 40 (python):
```python
sc.pl.umap(adata_raw, color=['donor'], frameon=False)
```

Example 41 (python):
```python
# save
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
```

Example 42 (python):
```python
# age
adata_raw.obs.replace({'age':{
    'PCW-11w':'11W0D',
    'PCW-13w':'13W0D',
    'PCW-14w':'14W0D',
}},inplace=True)

adata_raw.obs['week'] = [x.split('0D')[0] for x in adata_raw.obs['age']]
adata_raw.obs['trimester'] = adata_raw.obs['age'].astype('str').copy()
adata_raw.obs.replace({'trimester':{
    '11W0D':'firsttrimester',
    '13W0D':'secondtrimester',
    '14W0D':'secondtrimester',
}},inplace=True)
```

Example 43 (python):
```python
adata_raw.obs.drop(['gender'],axis=1,inplace=True)
```

Example 44 (python):
```python
# sex
adata_raw.obs['sex'] = adata_raw.obs['donor'].astype('str').copy()
adata_raw.obs.replace({'sex':{
    'Hst32':'female',
    'Hst42':'male',
    'Hst44':'male',
    'Hst48':'male'
}},inplace=True)
```

Example 45 (python):
```python
# save
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
adata_raw
```

Example 46 (unknown):
```unknown
... storing 'week' as categorical
... storing 'trimester' as categorical
... storing 'sex' as categorical
```

Example 47 (unknown):
```unknown
AnnData object with n_obs × n_vars = 110693 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'week', 'trimester', 'sex'
    var: 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'gene_id'
    uns: 'age_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap', 'cells_to_remove_colors', 'celltypist_coarse_colors'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 48 (python):
```python
adata_raw = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
adata_raw
```

Example 49 (unknown):
```unknown
AnnData object with n_obs × n_vars = 110693 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'week', 'trimester', 'sex', 'celltypist_fine', 'conf_score_fine'
    var: 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'gene_id'
    uns: 'age_colors', 'cells_to_remove_colors', 'celltypist_coarse_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 50 (python):
```python
adata = adata_raw.copy()
sc.pp.filter_genes(adata, min_cells=3)
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
adata.X.data[:5]
```

Example 51 (unknown):
```unknown
filtered out 3663 genes that are detected in less than 3 cells
normalizing counts per cell
    finished (0:00:00)
```

Example 52 (unknown):
```unknown
array([0.0534004 , 0.10409318, 0.19836526, 0.0534004 , 0.15233971],
      dtype=float32)
```

Example 53 (python):
```python
adata.obs['celltypist_coarse'].value_counts()
```

Example 54 (unknown):
```unknown
Mesenchymal       49009
Cardiomyocytes    42792
Endothelium        8089
Leukocytes         7262
Epicardium         2071
Neural             1470
Name: celltypist_coarse, dtype: int64
```

Example 55 (python):
```python
# predict per coarse_grained cell type
for celltype in adata.obs['celltypist_coarse'].unique():
    print(celltype)
    # subset adata
    adata_sub = adata[adata.obs['celltypist_coarse']==celltype]
    # drop all the obs columns
    adata_sub.obs.drop(columns=adata_sub.obs.columns,inplace=True)
    # predict
    predictions = celltypist.annotate(adata_sub, 
                                      model = f'/nfs/team205/kk18/notebooks/Foetal/Trisomy21/celltypist_models/coarse2fine_{celltype}.pkl', 
                                      majority_voting = False)

    # add to subsetted anndata
    adata_sub = predictions.to_adata(insert_labels = True, insert_conf = True)
    adata_sub.obs.rename(columns={'predicted_labels':'celltypist_fine',
                                  'conf_score':'conf_score_fine'
                                 },inplace=True)
    # add to the original anndata
    adata.obs.loc[adata_sub.obs_names,'celltypist_fine'] = list(adata_sub.obs['celltypist_fine'])
    adata.obs.loc[adata_sub.obs_names,'conf_score_fine'] = list(adata_sub.obs['conf_score_fine'])
```

Example 56 (unknown):
```unknown
Mesenchymal
```

Example 57 (unknown):
```unknown
🔬 Input data has 49009 cells and 32938 genes
🔗 Matching reference genes in the model
🧬 32502 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
🔬 Input data has 8089 cells and 32938 genes
🔗 Matching reference genes in the model
```

Example 58 (unknown):
```unknown
Endothelium
```

Example 59 (unknown):
```unknown
🧬 31696 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
🔬 Input data has 2071 cells and 32938 genes
🔗 Matching reference genes in the model
```

Example 60 (unknown):
```unknown
🧬 30529 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
```

Example 61 (unknown):
```unknown
Cardiomyocytes
```

Example 62 (unknown):
```unknown
🔬 Input data has 42792 cells and 32938 genes
🔗 Matching reference genes in the model
🧬 31533 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
🔬 Input data has 1470 cells and 32938 genes
🔗 Matching reference genes in the model
```

Example 63 (unknown):
```unknown
🧬 29361 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
🔬 Input data has 7262 cells and 32938 genes
🔗 Matching reference genes in the model
```

Example 64 (unknown):
```unknown
🧬 31793 features used for prediction
⚖️ Scaling input data
🖋️ Predicting labels
✅ Prediction done!
```

Example 65 (python):
```python
# add prediction results
adata_raw.obs[['celltypist_fine','conf_score_fine']] = adata[adata_raw.obs_names].obs[['celltypist_fine','conf_score_fine']].copy()
```

Example 66 (python):
```python
sc.pl.umap(adata_raw, color=['conf_score_fine','celltypist_fine'], frameon=False)
```

Example 67 (python):
```python
sc.pl.umap(adata_raw, color=['celltypist_coarse'], frameon=False)
```

Example 68 (python):
```python
# save
adata_raw.write('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.h5ad')
adata_raw
```

Example 69 (unknown):
```unknown
AnnData object with n_obs × n_vars = 110693 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', 'leiden_scVI_0.1', 'leiden_scVI_0.2', 'leiden_scVI_0.3', 'leiden_scVI_0.5', 'leiden_scVI_0.7', 'leiden_scVI_1', 'celltypist_coarse', 'conf_score_coarse', 'cells_to_remove', 'week', 'trimester', 'sex', 'celltypist_fine', 'conf_score_fine'
    var: 'feature_type', 'ambient_expression-0', 'ambient_expression-1', 'ambient_expression-10', 'ambient_expression-11', 'ambient_expression-12', 'ambient_expression-13', 'ambient_expression-14', 'ambient_expression-2', 'ambient_expression-3', 'ambient_expression-4', 'ambient_expression-5', 'ambient_expression-6', 'ambient_expression-7', 'ambient_expression-8', 'ambient_expression-9', 'mt', 'ribo', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'gene_id'
    uns: 'age_colors', 'cells_to_remove_colors', 'celltypist_coarse_colors', 'donor_colors', 'leiden', 'leiden_scVI_0.1_colors', 'leiden_scVI_0.2_colors', 'leiden_scVI_0.3_colors', 'leiden_scVI_0.5_colors', 'leiden_scVI_0.7_colors', 'leiden_scVI_1_colors', 'neighbors', 'region_colors', 'sangerID_colors', 'umap', 'celltypist_fine_colors'
    obsm: 'X_scVI', 'X_umap', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 70 (python):
```python
# save .obs for later use
adata_raw.obs.to_csv('/nfs/team205/heart/anndata_objects/Foetal/trisomy21/T21Hearts_cleaned_July2024.obs.csv')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Mesenchymal/Figure2SMCs.html

**Contents:**
- SMCs fro apex or base¶
- Pulmonary with only GVSMCs¶
- PA related cell types¶

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=150, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-09-18 17:07.
```

Example 5 (python):
```python
sc.settings.set_figure_params(dpi=150, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
```

Example 6 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
set(adata.obs.fine_grain)
```

Example 7 (unknown):
```unknown
(297473, 36601)
```

Example 8 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParasympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 9 (python):
```python
#Expression: "YlGn" (e.g. DE plots)
#Divergent expression: "PRGn" (e.g. log2FC)
#Age: "afmhot_r"
#Others: "viridis" (e.g. UMAP expression)

#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodePacemakerCells':'#854834',
    'AtrioventricularNodePacemakerCells':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParasympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 10 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 11 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 12 (python):
```python
set(adata.obs.fine_grain)
```

Example 13 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParasympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 14 (python):
```python
set(adata.obs.region)
```

Example 15 (unknown):
```unknown
{'aorta',
 'atria',
 'atrial septum',
 'ductus arteriosus',
 'left ventricle',
 'pericardium',
 'pulmonary arches and branches',
 'right ventricle',
 'right ventricle and papillaries'}
```

Example 16 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselSmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','CoronarySmoothMuscleCells','CoronaryPericytes','CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','GreatVesselAdventitialFibroblasts','CoronaryVesselAdventitialFibroblasts','Myofibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts'])].copy()
set(adata.obs.fine_grain)
adata
```

Example 17 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
```

Example 18 (python):
```python
normalizing counts per cell
    finished (0:00:01)
extracting highly variable genes
    finished (0:00:16)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
2520
```

Example 19 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'PCNA', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    288 total control genes are used. (0:00:01)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['CKS1B', 'TMPO', 'ANP32E', 'RANGAP1', 'NCAPD2', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    572 total control genes are used. (0:00:01)
-->     'phase', cell cycle phase (adata.obs)
```

Example 20 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 21 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [11:57<00:00, 14.35s/it, loss=921, v_num=1]
```

Example 22 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    342 total control genes are used. (0:00:01)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    348 total control genes are used. (0:00:01)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:13)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:45)
```

Example 23 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 24 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 25 (python):
```python
#adata.write('./25MayAllECSMCandFib.h5ad')
```

Example 26 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
```

Example 27 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselSmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','CoronarySmoothMuscleCells','CoronaryPericytes'])].copy()
set(adata.obs.fine_grain)
adata



# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
```

Example 28 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:10)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1505
```

Example 29 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    328 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['ANP32E', 'CDC25C', 'RANGAP1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    598 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 30 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 31 (unknown):
```unknown
Epoch 15/50:  28%|███        | 14/50 [00:35<01:31,  2.54s/it, loss=710, v_num=1]
```

Example 32 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    341 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBE1', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    245 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:03)
computing UMAP
```

Example 33 (python):
```python
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/tmp/ipykernel_61186/1485025011.py in <module>
     54 
     55 sc.pp.neighbors(adata, use_rep="X_scVI")
---> 56 sc.tl.umap(adata,min_dist=0.1)
     57 #sc.tl.tsne(adata)
     58 sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/tools/_umap.py in umap(adata, min_dist, spread, n_components, maxiter, alpha, gamma, negative_sample_rate, init_pos, random_state, a, b, copy, method, neighbors_key)
    191         # for the init condition in the UMAP embedding
    192         n_epochs = 0 if maxiter is None else maxiter
--> 193         X_umap = simplicial_set_embedding(
    194             X,
    195             neighbors['connectivities'].tocoo(),

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/umap_.py in simplicial_set_embedding(data, graph, n_components, initial_alpha, a, b, gamma, negative_sample_rate, n_epochs, init, random_state, metric, metric_kwds, verbose)
    954     elif isinstance(init, str) and init == "spectral":
    955         # We add a little noise to avoid local minima for optimization to come
--> 956         initialisation = spectral_layout(
    957             data,
    958             graph,

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/spectral.py in spectral_layout(data, graph, dim, random_state, metric, metric_kwds)
    256     try:
    257         if L.shape[0] < 2000000:
--> 258             eigenvalues, eigenvectors = scipy.sparse.linalg.eigsh(
    259                 L,
    260                 k,

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py in eigsh(A, k, M, sigma, which, v0, ncv, maxiter, tol, return_eigenvectors, Minv, OPinv, mode)
   1688     with _ARPACK_LOCK:
   1689         while not params.converged:
-> 1690             params.iterate()
   1691 
   1692         return params.extract(return_eigenvectors)

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py in iterate(self)
    534     def iterate(self):
    535         self.ido, self.tol, self.resid, self.v, self.iparam, self.ipntr, self.info = \
--> 536             self._arpack_solver(self.ido, self.bmat, self.which, self.k,
    537                                 self.tol, self.resid, self.v, self.iparam,
    538                                 self.ipntr, self.workd, self.workl, self.info)

KeyboardInterrupt:
```

Example 34 (unknown):
```unknown
<Figure size 600x600 with 0 Axes>
```

Example 35 (python):
```python
gene = 'PDE1C'

key_1 = 'week'
key_2 = 'fine_grain'
sc.settings.set_figure_params(dpi=80, facecolor='white')
plt.rcParams['figure.figsize'] =4,3  # width, height

# subset anndata of a gene of interest
ad = adata[:,list(adata.var_names).index(gene)]
# add gene expression to .obs
ad.obs[gene] = ad.to_df()
# groupby two keys
# ths is mean expression
df = ad.obs[[key_1,key_2,gene]]

sns.lineplot(x=key_1, y=gene,
             hue=key_2,
             data=df, err_style='band').legend(loc='center left',bbox_to_anchor=(1.0,0.5))
plt.xticks(rotation=45)
plt.ylabel("PDE1C expression")
plt.savefig('PDE1CExpression.pdf')
```

Example 36 (unknown):
```unknown
Trying to set attribute `.obs` of view, copying.
```

Example 37 (python):
```python
sc.settings.set_figure_params(dpi=150, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
```

Example 38 (python):
```python
sc.pl.dotplot(adata, ['ROBO2','DCLK2','PDE1C','TAFA1','CSMD1','PTGER4','PTGER3','PDE3A','PDE4D','PDE5A','EDNRA','EDNRB'],groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 39 (python):
```python
sc.pl.dotplot(adata, ['ROBO2','DCLK2','PDE1C','TAFA1','CSMD1','PTGER4','EDNRA','EDNRB','PDE3A','PDE4D','PDE5A'],groupby='fine_grain',standard_scale='var',cmap='YlGn')
```

Example 40 (python):
```python
FineGrainCategoriesOrder=['GreatVesselSmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','GreatVesselAdventitialFibroblasts','CoronarySmoothMuscleCells','CoronaryPericytes','CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','CoronaryVesselAdventitialFibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts','Myofibroblasts']
sc.pl.dotplot(adata, ['NLGN1','FOS','FOSB','PCDH7','COLEC12','FN1','FBN1','ELN','FBLN5','HSPG2','DCN','AGRN','TNC'], var_group_rotation=30,groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn',var_group_positions=[(0,4),(5,12)], var_group_labels=['great vessel enriched','extracellular matrix'])
```

Example 41 (python):
```python
FineGrainCategoriesOrder=['GreatVesselSmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','GreatVesselAdventitialFibroblasts','CoronarySmoothMuscleCells','CoronaryPericytes','CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','CoronaryVesselAdventitialFibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts','Myofibroblasts']
sc.pl.dotplot(adata, ['NLGN1','FOS','FOSB','PCDH7','COLEC12','FN1','FBN1','ELN','FBLN5','HSPG2','DCN','AGRN','TNC'], var_group_rotation=30,groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn',var_group_positions=[(0,4),(5,12)], var_group_labels=['great vessel enriched','extracellular matrix'])
```

Example 42 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselSmoothMuscleCells'])].copy()
```

Example 43 (python):
```python
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)
sc.pl.umap(adata, color='region',groups=['apex','left ventricle','right ventricle','right ventricle and papillaries'])
sc.pl.umap(adata, color='region',groups=['pulmonary arches and branches'])
```

Example 44 (python):
```python
#Pulmonary Vessel Smooth Muscle Cells
sc.tl.leiden(adata, resolution=0.3, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
sc.pl.umap(adata, color='leiden',legend_loc='on data',groups='2')
```

Example 45 (python):
```python
running Leiden clustering
    finished: found 7 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:02)
```

Example 46 (python):
```python
adata.obs['fine_grain2']= 'na'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.fine_grain[x]=='DuctusArteriosusSmoothMuscleCells']]='DuctusArteriosusSmoothMuscleCells'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.fine_grain[x]=='CoronarySmoothMuscleCells']]='CoronarySmoothMuscleCells'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.fine_grain[x]=='CoronaryPericytes']]='CoronaryPericytes'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.fine_grain[x]=='GreatVesselSmoothMuscleCells']]='OtherGreatVesselSmoothMuscleCells'
adata.obs['fine_grain2'][[x for x in adata.obs_names if adata.obs.leiden[x] in ['2']]]='PulmonaryArterySmoothMuscleCells'
sc.pl.umap(adata, color='fine_grain2')
```

Example 47 (unknown):
```unknown
... storing 'fine_grain2' as categorical
```

Example 48 (python):
```python
CategoriesOrder=['PulmonaryArterySmoothMuscleCells','OtherGreatVesselSmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','CoronarySmoothMuscleCells','CoronaryPericytes']
sc.pl.dotplot(adata, ['MYH11','ARL15','LAMA2','INPP4B','PXDNL','ALDH1A2','ESRRG','HPSE2','CACNA2D3'] ,groupby='fine_grain2',categories_order=CategoriesOrder,standard_scale='var',cmap='YlGn')
sc.pl.umap(adata, color='BMPR2')
```

Example 49 (python):
```python
adata.obs['Pulmonary']= 'OtherMuralCells'
adata.obs['Pulmonary'][[x for x in adata.obs_names if adata.obs.leiden[x] in ['2']]]='PulmonaryVesselSmoothMuscleCells'
#Final pulmonary genes
sc.pl.umap(adata, color='Pulmonary')
sc.pl.umap(adata, color='region',groups=['pulmonary arches and branches'])
sc.pl.dotplot(adata, ['PXDNL','ALDH1A2','ESRRG','HPSE2','CACNA2D3','ARL15','INPP4B','LAMA2','BMPR2'] ,groupby='Pulmonary',standard_scale='var',cmap='YlGn')
```

Example 50 (unknown):
```unknown
... storing 'Pulmonary' as categorical
```

Example 51 (python):
```python
ClusterOfInterest='CoronarySmoothMuscleCells'
sc.tl.rank_genes_groups(adata, 'fine_grain2', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain2',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 52 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
```

Example 53 (python):
```python
bdata=adata[adata.obs.fine_grain2=='PulmonaryArterySmoothMuscleCells',:].copy()
bdatanames=bdata.obs_names

np.savetxt('./PulmonarySMCRelatedCellIndex/PulmonaryArterySmoothMuscleCells.txt', bdatanames, delimiter="\n", fmt="%s")
```

Example 54 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselSmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','CoronarySmoothMuscleCells','CoronaryPericytes'])].copy()
adata = adata[adata.obs['donor'].isin(['BRC2253','BRC2256','BRC2260','BRC2262','BRC2251','BRC2263'])].copy()
print(adata.shape)

# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.2)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
sc.pl.umap(adata, color='region')
```

Example 55 (python):
```python
(5989, 36601)
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:02)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
3391
```

Example 56 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM2', 'RRM1', 'UNG', 'PRIM1', 'RFC2', 'RPA2', 'GMNN', 'WDR76', 'SLBP', 'UBR7', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    579 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['CDC25C', 'CDCA2', 'LBR', 'CTCF', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    658 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 57 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 58 (unknown):
```unknown
Epoch 50/50: 100%|██████| 50/50 [00:36<00:00,  1.36it/s, loss=1.38e+03, v_num=1]
```

Example 59 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    495 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    248 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:04)
```

Example 60 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 61 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 62 (python):
```python
sc.tl.leiden(adata, resolution=0.2, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 63 (python):
```python
running Leiden clustering
    finished: found 5 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 64 (python):
```python
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)
sc.pl.umap(adata, color='region',groups=['aorta','base','pulmonary arches and branches','atria','atrial septum','node','outflow tract'])
sc.pl.umap(adata, color='region',groups=['pulmonary arches and branches'])
```

Example 65 (python):
```python
sc.pl.umap(adata, color='SMCRegions',groups='DuctusArteriosusRegion')
OtherRegions=['aorta','atria','atrial septum','base','heart without node','node','outflow tract','pericardium','pulmonary arches and branches','whole sample']
ApexAssociatedRegions=['apex','left ventricle','right ventricle','right ventricle and papillaries']
DuctusArteriosusRegion=['ductus arteriosus']

adata.obs['SMCRegions']= 'na'
adata.obs['SMCRegions'][[x for x in adata.obs_names if adata.obs.region[x] in OtherRegions]]='OtherRegions'
adata.obs['SMCRegions'][[x for x in adata.obs_names if adata.obs.region[x] in ApexAssociatedRegions]]='ApexAssociatedRegions'
adata.obs['SMCRegions'][[x for x in adata.obs_names if adata.obs.region[x] in DuctusArteriosusRegion]]='DuctusArteriosusRegion'
sc.pl.umap(adata, color='SMCRegions')
```

Example 66 (python):
```python
adata = adata[adata.obs['week'].isin(['20W'])].copy()
adata = adata[adata.obs['region'].isin(['pulmonary arches and branches','aorta'])].copy()
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselSmoothMuscleCells','GreatVesselAdventitialFibroblasts','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
set(adata.obs.fine_grain)
adata
```

Example 67 (unknown):
```unknown
AnnData object with n_obs × n_vars = 22161 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 68 (python):
```python
set(adata.obs.fine_grain)
```

Example 69 (unknown):
```unknown
{'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells'}
```

Example 70 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
adata
```

Example 71 (unknown):
```unknown
AnnData object with n_obs × n_vars = 2977 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 72 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
```

Example 73 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:06)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
915
```

Example 74 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['FEN1', 'MCM2', 'MCM4', 'RRM1', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    293 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['CKS1B', 'TMPO', 'TACC3', 'CKAP2L', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'HJURP', 'CDCA3', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'CDCA2', 'CDCA8', 'AURKA', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    392 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 75 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 76 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:10<00:00,  4.87it/s, loss=655, v_num=1]
```

Example 77 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1', 'BTG2']
    finished: added
    'stress_score', score of gene set (adata.obs).
    252 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBB', 'HBD', 'HBE1', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    185 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:00)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:01)
```

Example 78 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 79 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 80 (python):
```python
sc.tl.leiden(adata, resolution=0.1, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 81 (python):
```python
running Leiden clustering
    finished: found 3 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 82 (python):
```python
ClusterOfInterest='0'
sc.tl.rank_genes_groups(adata, 'leiden', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='leiden',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 83 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 84 (python):
```python
adata.obs['type']= 'na'
adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselAdventitialFibroblasts']]]='Fibroblasts'
adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselSmoothMuscleCells']]]='SmoothMusleCells'
adata.obs['type'][[x for x in adata.obs_names if adata.obs.fine_grain[x] in ['GreatVesselArterialEndothelialCells','GreatVesselArterialEndothelialCells']]]='EndothelialCells'
```

Example 85 (python):
```python
set(adata.obs.mid_grain)
```

Example 86 (unknown):
```unknown
{'BloodVesselEndothelialCells', 'Fibroblasts', 'MuralCells'}
```

Example 87 (python):
```python
set(adata.obs.region)
```

Example 88 (unknown):
```unknown
{'aorta', 'pulmonary arches and branches'}
```

Example 89 (python):
```python
PulmonaryEndothelial=adata[adata.obs.mid_grain=='BloodVesselEndothelialCells',:].copy()
PulmonaryEndothelial=PulmonaryEndothelial[PulmonaryEndothelial.obs.region=='pulmonary arches and branches',:].copy()
PulmonaryEndothelial.obs['type']= 'PulmonaryEndothelial'

AorticEndothelial=adata[adata.obs.mid_grain=='BloodVesselEndothelialCells',:].copy()
AorticEndothelial=AorticEndothelial[AorticEndothelial.obs.region=='aorta',:].copy()
AorticEndothelial.obs['type']= 'AorticEndothelial'

PulmonarySmoothMuscle=adata[adata.obs.mid_grain=='MuralCells',:].copy()
PulmonarySmoothMuscle=PulmonarySmoothMuscle[PulmonarySmoothMuscle.obs.region=='pulmonary arches and branches',:].copy()
PulmonarySmoothMuscle.obs['type']= 'PulmonarySmoothMuscle'

AorticSmoothMuscle=adata[adata.obs.mid_grain=='MuralCells',:].copy()
AorticSmoothMuscle=AorticSmoothMuscle[AorticSmoothMuscle.obs.region=='aorta',:].copy()
AorticSmoothMuscle.obs['type']= 'AorticSmoothMuscle'

PulmonaryAdventitialFibroblasts=adata[adata.obs.mid_grain=='Fibroblasts',:].copy()
PulmonaryAdventitialFibroblasts=PulmonaryAdventitialFibroblasts[PulmonaryAdventitialFibroblasts.obs.region=='pulmonary arches and branches',:].copy()
PulmonaryAdventitialFibroblasts.obs['type']= 'PulmonaryAdventitialFibroblasts'

AorticAdventitialFibroblasts=adata[adata.obs.mid_grain=='Fibroblasts',:].copy()
AorticAdventitialFibroblasts=AorticAdventitialFibroblasts[AorticAdventitialFibroblasts.obs.region=='aorta',:].copy()
AorticAdventitialFibroblasts.obs['type']= 'AorticAdventitialFibroblasts'

bdata = PulmonaryEndothelial.concatenate(AorticEndothelial,PulmonarySmoothMuscle,AorticSmoothMuscle,PulmonaryAdventitialFibroblasts,AorticAdventitialFibroblasts)
```

Example 90 (python):
```python
sc.pl.umap(bdata, color=['type'])
```

Example 91 (unknown):
```unknown
... storing 'sangerID' as categorical
... storing 'combinedID' as categorical
... storing 'region' as categorical
... storing 'fine_grain' as categorical
... storing 'mid_grain' as categorical
... storing 'coarse_grain' as categorical
... storing 'type' as categorical
```

Example 92 (python):
```python
adata = bdata[bdata.obs['type'].isin(['PulmonaryEndothelial','AorticEndothelial'])].copy()
```

Example 93 (python):
```python
# Pulmonary region ECs have both arterial and venous markers
Genes=['KCNIP4','ADGRG6','MPP7','TSHZ2','PDE7B','NTS','DKK2','FBLN5','ENOX1','HEY2','PDGFD','RELN','GJA5']
CategoriesOrder=['PulmonaryEndothelial','AorticEndothelial']
sc.pl.dotplot(adata,Genes, groupby='type',categories_order=CategoriesOrder,cmap='YlGn',var_group_rotation=45)
```

Example 94 (python):
```python
tmp = pd.crosstab(adata.obs['type'],adata.obs['fine_grain'], normalize='index')
plt.rcParams['figure.figsize'] = [3,2]
tmp.plot.bar(stacked=True).legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
```

Example 95 (python):
```python
<matplotlib.legend.Legend at 0x7fdc606270a0>
```

Example 96 (python):
```python
ClusterOfInterest='GreatVesselArterialEndothelialCells'
sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 97 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 98 (python):
```python
ClusterOfInterest='GreatVesselVenousEndothelialCells'
sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 99 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 100 (python):
```python
Genes=['MTRNR2L12','NAP1L1','HSP90AA1','NUCKS1','HDLBP','SERBP1','NPM1','MTDH','NCL','NRG1','IL33','EDN1','PVT1','RAPGEF4','PDE7B','KCNIP4','ADGRG6','DPYD','IGFBP3','NTS','INPP4B','LAMA2','PXDNL','ALDH1A2','HPSE2','CACNA2D3','TMEM132C','ESRRG','SIPA1L2','PRRX1','NR2F2','IGFBP5','HSPA1A','SLC4A4']
CategoriesOrder=['PulmonaryEndothelial','PulmonarySmoothMuscle','PulmonaryAdventitialFibroblasts','AorticEndothelial','AorticSmoothMuscle','AorticAdventitialFibroblasts']
sc.pl.dotplot(bdata,Genes, groupby='type',standard_scale='var',categories_order=CategoriesOrder,cmap='YlGn',var_group_positions=[(9,19),(20,28),(29,32)], var_group_labels=['pulmonary endothelial','pulmonary smooth muscle','pulmonary adventitial'], var_group_rotation=45)
```

Example 101 (python):
```python
sc.pl.dotplot(bdata,['NR2F2'], groupby='type',standard_scale='var',categories_order=CategoriesOrder,cmap='YlGn', var_group_rotation=45)
```

Example 102 (python):
```python
bdata.obs['AorticOrPulmonary']= 'na'
bdata.obs['AorticOrPulmonary'][[x for x in bdata.obs_names if bdata.obs.type[x] in ['AorticAdventitialFibroblasts','AorticEndothelial','AorticSmoothMuscle']]]='Aortic'
bdata.obs['AorticOrPulmonary'][[x for x in bdata.obs_names if bdata.obs.type[x] in ['PulmonaryAdventitialFibroblasts','PulmonaryEndothelial','PulmonarySmoothMuscle']]]='Pulmonary'
sc.pl.umap(bdata, color=['AorticOrPulmonary'])
```

Example 103 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 104 (python):
```python
ClusterOfInterest='Pulmonary'
sc.tl.rank_genes_groups(bdata, 'AorticOrPulmonary', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in bdata.uns['t-test']['names'][:50]]
CategoriesOrder=['AorticEndothelial','AorticSmoothMuscle','AorticAdventitialFibroblasts','PulmonaryEndothelial','PulmonarySmoothMuscle','PulmonaryAdventitialFibroblasts']
sc.pl.dotplot(bdata, DEGenesForCluster ,groupby='type',categories_order=CategoriesOrder,standard_scale='var',cmap='PRGn')
#sc.pl.umap(bdata, color=DEGenesForCluster)
```

Example 105 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 106 (python):
```python
sc.pl.dotplot(bdata, ['MTRNR2L12','NAP1L1','NUCKS1','HDLBP','SERBP1','NPM1','MTDH','NCL',] ,groupby='type',categories_order=CategoriesOrder,standard_scale='var',cmap='YlGn')
```

Example 107 (python):
```python
set(adata.obs.region)
```

Example 108 (unknown):
```unknown
{'aorta',
 'apex',
 'atria',
 'atrial septum',
 'base',
 'ductus arteriosus',
 'heart without node',
 'left ventricle',
 'node',
 'outflow tract',
 'pericardium',
 'pulmonary arches and branches',
 'right ventricle',
 'right ventricle and papillaries',
 'whole sample'}
```

Example 109 (python):
```python
adata = adata[adata.obs['week'].isin(['20W'])].copy()
adata = adata[adata.obs['region'].isin(['pulmonary arches and branches','aorta','ductus arteriosus'])].copy()
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
set(adata.obs.fine_grain)
adata
```

Example 110 (unknown):
```unknown
AnnData object with n_obs × n_vars = 1272 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 111 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
```

Example 112 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:01)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
5300
```

Example 113 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'MCM2', 'UNG', 'MCM6', 'CDCA7', 'DTL', 'UHRF1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'SLBP', 'CCNE2', 'UBR7', 'MSH2', 'RAD51', 'CDC45', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    500 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'CKAP2L', 'HJURP', 'CDCA3', 'TTK', 'RANGAP1', 'AURKA', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'CBX5', 'CENPA']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    707 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 114 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 115 (unknown):
```unknown
Epoch 50/50: 100%|██████| 50/50 [00:12<00:00,  4.05it/s, loss=1.83e+03, v_num=1]
```

Example 116 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'CEBPB', 'EGR1', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPE1', 'IER2', 'BTG1', 'DUSP1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    200 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBE1', 'HBZ', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    198 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:00)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:00)
```

Example 117 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 118 (unknown):
```unknown
<Figure size 600x600 with 0 Axes>
```

Example 119 (python):
```python
sc.tl.leiden(adata, resolution=0.25, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 120 (python):
```python
running Leiden clustering
    finished: found 6 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 121 (python):
```python
sc.pl.dotplot(adata, ['PDE4D','GADD45B','CCNL1','ICAM1','POU4F1','IER3','CHRM3','GHR','TNFRSF10D','GPRC5A','NAMPT','PEX5L','DEPP1','ADCY2','SLC2A3','TBX1'], categories_order=['ductus arteriosus','pulmonary arches and branches','aorta'],groupby='region',standard_scale='var',cmap='YlGn',title='great vessel endothelial cells')
```

Example 122 (python):
```python
sc.pl.dotplot(adata, ['PDE4D','GADD45B','CCNL1','ICAM1','POU4F1','IER3','CHRM3','GHR','TNFRSF10D','GPRC5A','NAMPT','PEX5L','DEPP1','ADCY2','SLC2A3','TBX1','HIF1A','EPAS1','NFE2L2','PTGS2','PTGES3','PTGDS','PTGDS'], categories_order=['ductus arteriosus','pulmonary arches and branches','aorta'],groupby='region',standard_scale='var',cmap='YlGn',title='great vessel endothelial cells')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Endothelial/Figure2EndothelialCells.html

36601 rows × 5 columns

36601 rows × 5 columns

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (python):
```python
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 8
      6 import pandas as pd
      7 import anndata
----> 8 import scrublet as scr
      9 import seaborn as sns
     10 import six

ModuleNotFoundError: No module named 'scrublet'
```

Example 4 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 5 (python):
```python
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodeCardiomyocytes':'#854834',
    'AtrioventricularNodeCardiomyocytes':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts1':'#8a6800',
    'MyocardialInterstitialFibroblasts2':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCells1':'#c95e00',
    'PericardialCells2':'#01e077',
    'PericardialCells3':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)
```

Example 6 (python):
```python
set(adata.obs.fine_grain)
```

Example 7 (python):
```python
adata = adata[adata.obs['fine_grain'].isin(['GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells'])].copy()
adata=adata[adata.obs.cycling=='no',:].copy()
```

Example 8 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 9 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 10 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
```

Example 11 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:08)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1634
```

Example 12 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'MCM2', 'MCM4', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'UHRF1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'CDC45', 'CDC6', 'EXO1', 'DSCC1', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    411 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'CKAP2L', 'ANP32E', 'CDCA3', 'RANGAP1', 'NCAPD2', 'CDCA2', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    732 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 13 (python):
```python
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/torchmetrics/utilities/prints.py:36: UserWarning: Torchmetrics v0.9 introduced a new argument class property called `full_state_update` that has
                not been set for this class (ElboMetric). The property determines if `update` by
                default needs access to the full metric state. If this is not the case, significant speedups can be
                achieved and we recommend setting this to `False`.
                We provide an checking function
                `from torchmetrics.utilities import check_forward_no_full_state`
                that can be used to check if the `full_state_update=True` (old and potential slower behaviour,
                default for now) or if `full_state_update=False` can be used safely.
                
  warnings.warn(*args, **kwargs)
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 14 (unknown):
```unknown
Epoch 1/50:   0%|                                        | 0/50 [00:00<?, ?it/s]
```

Example 15 (python):
```python
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/torchmetrics/utilities/prints.py:36: UserWarning: Torchmetrics v0.9 introduced a new argument class property called `full_state_update` that has
                not been set for this class (ResultMetric). The property determines if `update` by
                default needs access to the full metric state. If this is not the case, significant speedups can be
                achieved and we recommend setting this to `False`.
                We provide an checking function
                `from torchmetrics.utilities import check_forward_no_full_state`
                that can be used to check if the `full_state_update=True` (old and potential slower behaviour,
                default for now) or if `full_state_update=False` can be used safely.
                
  warnings.warn(*args, **kwargs)
```

Example 16 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:51<00:00,  1.03s/it, loss=806, v_num=1]
```

Example 17 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    389 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    294 total control genes are used. (0:00:00)
computing neighbors
```

Example 18 (python):
```python
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/numba/core/typed_passes.py:313: NumbaPerformanceWarning: 
The keyword argument 'parallel=True' was specified but no transformation for parallel execution was possible.

To find out why, try turning on parallel diagnostics, see https://numba.pydata.org/numba-doc/latest/user/parallel.html#diagnostics for help.

File "../../miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/rp_tree.py", line 135:
@numba.njit(fastmath=True, nogil=True, parallel=True)
def euclidean_random_projection_split(data, indices, rng_state):
^

  warnings.warn(errors.NumbaPerformanceWarning(msg,
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/nndescent.py:91: NumbaPerformanceWarning: 
The keyword argument 'parallel=True' was specified but no transformation for parallel execution was possible.

To find out why, try turning on parallel diagnostics, see https://numba.pydata.org/numba-doc/latest/user/parallel.html#diagnostics for help.

File "../../miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/utils.py", line 409:
@numba.njit(parallel=True)
def build_candidates(current_graph, n_vertices, n_neighbors, max_candidates, rng_state):
^

  candidate_neighbors = build_candidates(
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/numba/core/typed_passes.py:313: NumbaPerformanceWarning: 
The keyword argument 'parallel=True' was specified but no transformation for parallel execution was possible.

To find out why, try turning on parallel diagnostics, see https://numba.pydata.org/numba-doc/latest/user/parallel.html#diagnostics for help.

File "../../miniconda3/envs/scanpynew/lib/python3.8/site-packages/umap/nndescent.py", line 47:
    @numba.njit(parallel=True)
    def nn_descent(
    ^

  warnings.warn(errors.NumbaPerformanceWarning(msg,
```

Example 19 (python):
```python
finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:03)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:03)
```

Example 20 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/_core/anndata.py:1220: FutureWarning: The `inplace` parameter in pandas.Categorical.reorder_categories is deprecated and will be removed in a future version. Removing unused categories will always return a new Categorical object.
  c.reorder_categories(natsorted(c.categories), inplace=True)
... storing 'phase' as categorical
```

Example 21 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 22 (python):
```python
sc.tl.diffmap(adata)
sc.pl.diffmap(adata, color='fine_grain')
```

Example 23 (python):
```python
computing Diffusion Maps using n_comps=15(=n_dcs)
computing transitions
    finished (0:00:00)
    eigenvalues of transition matrix
    [1.         0.9950726  0.99062014 0.9852053  0.9790444  0.97708017
     0.97520936 0.9719767  0.96848094 0.9680828  0.9639776  0.96136785
     0.95495147 0.9540259  0.9515269 ]
    finished: added
    'X_diffmap', diffmap coordinates (adata.obsm)
    'diffmap_evals', eigenvalues of transition matrix (adata.uns) (0:00:00)
```

Example 24 (python):
```python
adata.write('./EndothelialCellsForscFatesDiffMapCellCyclingCellsIN.h5ad')
```

Example 25 (python):
```python
sc.pl.umap(adata, color=['fine_grain'], ncols=5,)
```

Example 26 (python):
```python
import pandas as pd
import numpy as np
import anndata


import scipy
import matplotlib.pyplot as plt
import scanpy as sc
import scFates as scf
import palantir

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42
plt.rcParams["font.family"] = "sans-serif"
sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 
import matplotlib.pyplot as plt
import matplotlib.font_manager

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 27 (unknown):
```unknown
findfont: Font family ['Raleway'] not found. Falling back to DejaVu Sans.
```

Example 28 (unknown):
```unknown
Running Scanpy 1.9.3, on 2023-09-19 11:55.
```

Example 29 (python):
```python
adata=sc.read('./EndothelialCellsForscFates.h5ad')
print(adata.shape)
```

Example 30 (unknown):
```unknown
(8359, 1450)
```

Example 31 (unknown):
```unknown
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
```

Example 32 (python):
```python
projections = pd.DataFrame(adata.obsm["X_scVI"],index=adata.obs_names)
projections
# fate probability mapping of the cells
dm_res = palantir.utils.run_diffusion_maps(projections)
ms_data = palantir.utils.determine_multiscale_space(dm_res,n_eigs=4)
# Generate embedding from the multiscale diffusion space
adata.obsm["X_palantir"]=ms_data.values
sc.pp.neighbors(adata,n_neighbors=30,use_rep="X_palantir")
sc.pl.embedding(adata, basis='X_palantir',color=['fine_grain'], components='all',ncols=3,wspace=0.6,size=10)

# draw ForceAtlas2 embedding using UMAP dim1 and dim2 as initial position
# make obsm with UMAP1 and 2
adata.obsm['X_umap12'] = adata.obsm['X_umap'][:,[0,1]]
sc.tl.draw_graph(adata,init_pos='X_umap12')
# Plot
sc.set_figure_params(dpi=120)
sc.pl.draw_graph(adata,color="fine_grain",color_map="RdBu_r")
```

Example 33 (unknown):
```unknown
Determing nearest neighbor graph...
computing neighbors
```

Example 34 (python):
```python
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
```

Example 35 (unknown):
```unknown
finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:10)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
```

Example 36 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 37 (python):
```python
drawing single-cell graph using layout 'fa'
WARNING: Package 'fa2' is not installed, falling back to layout 'fr'.To use the faster and better ForceAtlas2 layout, install package 'fa2' (`pip install fa2`).
    finished: added
    'X_draw_graph_fr', graph_drawing coordinates (adata.obsm) (0:00:10)
```

Example 38 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 39 (unknown):
```unknown
AnnData object with n_obs × n_vars = 8359 × 1450
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors', 'draw_graph'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding', 'X_palantir', 'X_umap12', 'X_draw_graph_fr'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 40 (python):
```python
scf.tl.curve(adata,Nodes=30,use_rep="X_umap",ndims_rep=2,epg_lambda=0.0005,epg_mu=10)
scf.pl.graph(adata,basis="umap")
scf.tl.convert_to_soft(adata,1,1000)
scf.pl.graph(adata,basis="umap")
scf.tl.root(adata,"NR2F2")
scf.tl.pseudotime(adata,n_jobs=20,n_map=100,seed=42)
scf.pl.trajectory(adata,basis="umap",arrows=True,arrow_offset=3)
scf.pl.trajectory(adata,basis="umap",arrows=False,arrow_offset=3)
adata=adata.raw.to_adata()
```

Example 41 (python):
```python
inferring a principal curve --> parameters used 
    30 principal points, mu = 10, lambda = 0.0005
    finished (0:00:01) --> added 
    .uns['epg'] dictionnary containing inferred elastic curve generated from elpigraph.
    .obsm['X_R'] hard assignment of cells to principal points.
    .uns['graph']['B'] adjacency matrix of the principal points.
    .uns['graph']['F'], coordinates of principal points in representation space.
```

Example 42 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  cax = scatter(
```

Example 43 (unknown):
```unknown
Converting R into soft assignment matrix
    finished (0:00:00) --> updated 
    .obsm['X_R'] converted soft assignment of cells to principal points.
    .uns['graph']['F'] coordinates of principal points in representation space.
```

Example 44 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  cax = scatter(
```

Example 45 (python):
```python
automatic root selection using NR2F2 values
node 0 selected as a root --> added
    .uns['graph']['root'] selected root.
    .uns['graph']['pp_info'] for each PP, its distance vs root and segment assignment.
    .uns['graph']['pp_seg'] segments network information.
projecting cells onto the principal graph
    mappings: 100%|███████████████████████████| 100/100 [00:30<00:00,  3.31it/s]
    finished (0:00:32) --> added
    .obs['edge'] assigned edge.
    .obs['t'] pseudotime value.
    .obs['seg'] segment of the tree assigned.
    .obs['milestones'] milestone assigned.
    .uns['pseudotime_list'] list of cell projection from all mappings.
```

Example 46 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  cax = scatter(
```

Example 47 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  cax = scatter(
```

Example 48 (python):
```python
scf.tl.linearity_deviation(adata,start_milestone="0",end_milestone="2",n_jobs=20,plot=True,basis="umap")
scf.pl.linearity_deviation(adata,start_milestone="0",end_milestone="2")
sc.pl.umap(adata,color=["H19","IGFBP3","PDGFB"])
```

Example 49 (python):
```python
Estimation of deviation from linearity
    cells on the bridge: 100%|█████████████| 5357/5357 [00:11<00:00, 469.64it/s]
```

Example 50 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scFates/tools/linearity_deviation.py:144: RuntimeWarning: invalid value encountered in divide
  return rs.mean(axis=1) / X_all.std(axis=0)
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  cax = scatter(
```

Example 51 (python):
```python
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scFates/tools/linearity_deviation.py:164: RuntimeWarning: Mean of empty slice
  adata.var[name + "_rss"] = np.nanmean(np.vstack(rss), axis=0)
```

Example 52 (unknown):
```unknown
finished (0:00:17) --> added 
    .var['0->2_rss'], pearson residuals of the linear fit.
    .obs['0->2_lindev_sel'], cell selections used for the test.
```

Example 53 (python):
```python
scf.tl.test_association(adata,n_jobs=20)
scf.tl.test_association(adata,reapply_filters=True,A_cut=.5)
scf.pl.test_association(adata)
scf.tl.fit(adata,n_jobs=20)
```

Example 54 (unknown):
```unknown
test features for association with the trajectory
    single mapping :  10%|█▋               | 3665/36601 [01:19<11:55, 46.06it/s]
```

Example 55 (python):
```python
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
Cell In[9], line 1
----> 1 scf.tl.test_association(adata,n_jobs=20)
      2 scf.tl.test_association(adata,reapply_filters=True,A_cut=.5)
      3 scf.pl.test_association(adata)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/scFates/tools/test_association.py:162, in test_association(adata, n_map, n_jobs, spline_df, fdr_cut, A_cut, st_cut, reapply_filters, plot, copy, layer)
    159     stat["fdr"] = multipletests(stat.p_val, method="bonferroni")[1]
    160     return stat
--> 162 stat_assoc_l = ProgressParallel(
    163     n_jobs=1 if n_map == 1 else n_jobs,
    164     total=n_map,
    165     file=sys.stdout,
    166     use_tqdm=n_map > 1,
    167     desc="    multi mapping ",
    168 )(delayed(test_assoc_map)(m) for m in range(n_map))
    170 adata = apply_filters(adata, stat_assoc_l, fdr_cut, A_cut, st_cut)
    172 logg.info(
    173     "    found " + str(sum(adata.var["signi"])) + " significant features",
    174     time=True,
    175     end=" " if settings.verbosity > 2 else "\n",
    176 )

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/scFates/tools/utils.py:46, in ProgressParallel.__call__(self, *args, **kwargs)
     39 def __call__(self, *args, **kwargs):
     40     with tqdm(
     41         disable=not self._use_tqdm,
     42         total=self._total,
     43         desc=self._desc,
     44         file=self._file,
     45     ) as self._pbar:
---> 46         return Parallel.__call__(self, *args, **kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/parallel.py:1085, in Parallel.__call__(self, iterable)
   1076 try:
   1077     # Only set self._iterating to True if at least a batch
   1078     # was dispatched. In particular this covers the edge
   (...)
   1082     # was very quick and its callback already dispatched all the
   1083     # remaining jobs.
   1084     self._iterating = False
-> 1085     if self.dispatch_one_batch(iterator):
   1086         self._iterating = self._original_iterator is not None
   1088     while self.dispatch_one_batch(iterator):

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/parallel.py:901, in Parallel.dispatch_one_batch(self, iterator)
    899     return False
    900 else:
--> 901     self._dispatch(tasks)
    902     return True

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/parallel.py:819, in Parallel._dispatch(self, batch)
    817 with self._lock:
    818     job_idx = len(self._jobs)
--> 819     job = self._backend.apply_async(batch, callback=cb)
    820     # A job can complete so quickly than its callback is
    821     # called before we get here, causing self._jobs to
    822     # grow. To ensure correct results ordering, .insert is
    823     # used (rather than .append) in the following line
    824     self._jobs.insert(job_idx, job)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/_parallel_backends.py:208, in SequentialBackend.apply_async(self, func, callback)
    206 def apply_async(self, func, callback=None):
    207     """Schedule a func to be run"""
--> 208     result = ImmediateResult(func)
    209     if callback:
    210         callback(result)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/_parallel_backends.py:597, in ImmediateResult.__init__(self, batch)
    594 def __init__(self, batch):
    595     # Don't delay the application, to avoid keeping the input
    596     # arguments in memory
--> 597     self.results = batch()

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/parallel.py:288, in BatchedCalls.__call__(self)
    284 def __call__(self):
    285     # Set the default nested backend to self._backend but do not set the
    286     # change the default number of processes to -1
    287     with parallel_backend(self._backend, n_jobs=self._n_jobs):
--> 288         return [func(*args, **kwargs)
    289                 for func, args, kwargs in self.items]

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/parallel.py:288, in <listcomp>(.0)
    284 def __call__(self):
    285     # Set the default nested backend to self._backend but do not set the
    286     # change the default number of processes to -1
    287     with parallel_backend(self._backend, n_jobs=self._n_jobs):
--> 288         return [func(*args, **kwargs)
    289                 for func, args, kwargs in self.items]

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/scFates/tools/test_association.py:151, in test_association.<locals>.test_assoc_map(m)
    148     df = adata.uns["pseudotime_list"][str(m)]
    149 data = list(zip([df] * len(Xgenes), Xgenes))
--> 151 stat = ProgressParallel(
    152     n_jobs=n_jobs if n_map == 1 else 1,
    153     total=len(data),
    154     file=sys.stdout,
    155     use_tqdm=n_map == 1,
    156     desc="    single mapping ",
    157 )(delayed(test_assoc)(data[d], spline_df) for d in range(len(data)))
    158 stat = pd.DataFrame(stat, index=adata.var_names, columns=["p_val", "A"])
    159 stat["fdr"] = multipletests(stat.p_val, method="bonferroni")[1]

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/scFates/tools/utils.py:46, in ProgressParallel.__call__(self, *args, **kwargs)
     39 def __call__(self, *args, **kwargs):
     40     with tqdm(
     41         disable=not self._use_tqdm,
     42         total=self._total,
     43         desc=self._desc,
     44         file=self._file,
     45     ) as self._pbar:
---> 46         return Parallel.__call__(self, *args, **kwargs)

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/parallel.py:1098, in Parallel.__call__(self, iterable)
   1095     self._iterating = False
   1097 with self._backend.retrieval_context():
-> 1098     self.retrieve()
   1099 # Make sure that we get a last message telling us we are done
   1100 elapsed_time = time.time() - self._start_time

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/parallel.py:975, in Parallel.retrieve(self)
    973 try:
    974     if getattr(self._backend, 'supports_timeout', False):
--> 975         self._output.extend(job.get(timeout=self.timeout))
    976     else:
    977         self._output.extend(job.get())

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/joblib/_parallel_backends.py:567, in LokyBackend.wrap_future_result(future, timeout)
    564 """Wrapper for Future.result to implement the same behaviour as
    565 AsyncResults.get from multiprocessing."""
    566 try:
--> 567     return future.result(timeout=timeout)
    568 except CfTimeoutError as e:
    569     raise TimeoutError from e

File ~/miniconda3/envs/scFates/lib/python3.8/concurrent/futures/_base.py:439, in Future.result(self, timeout)
    436 elif self._state == FINISHED:
    437     return self.__get_result()
--> 439 self._condition.wait(timeout)
    441 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
    442     raise CancelledError()

File ~/miniconda3/envs/scFates/lib/python3.8/threading.py:302, in Condition.wait(self, timeout)
    300 try:    # restore state no matter what (e.g., KeyboardInterrupt)
    301     if timeout is None:
--> 302         waiter.acquire()
    303         gotit = True
    304     else:

KeyboardInterrupt:
```

Example 56 (python):
```python
scf.pl.single_trend(adata,"TCF4",basis="umap",color_exp="k")
scf.pl.single_trend(adata,"NR2F2",basis="umap",color_exp="k")
scf.pl.single_trend(adata,"APLN",basis="umap",color_exp="k")
scf.pl.single_trend(adata,"HEY2",basis="umap",color_exp="k")
```

Example 57 (python):
```python
scf.tl.cluster(adata,n_neighbors=20,metric="correlation")
adata.var.cluters.unique()
```

Example 58 (python):
```python
Clustering features using fitted layer
computing PCA
    with n_comps=50
    finished (0:00:01)
computing neighbors
    using 'X_pca' with n_pcs = 50
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
running Leiden clustering
    finished: found 11 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
    finished (0:00:02) --> added 
    .var['cluters'] identified modules.
```

Example 59 (unknown):
```unknown
['4', '9', '2', '8', '10', ..., '0', '6', '1', '3', '7']
Length: 11
Categories (11, object): ['0', '1', '2', '3', ..., '7', '8', '9', '10']
```

Example 60 (python):
```python
for c in adata.var["cluters"].unique():
    scf.pl.trends(adata,features=adata.var_names[adata.var.cluters==c],basis="umap")
```

Example 61 (python):
```python
scf.pl.trends(adata,features=['NR2F2', 'RGCC','TCF4','HEY2','COL4A1','COL4A2','HEY2'],basis="umap")
```

Example 62 (python):
```python
set(adata.obs.fine_grain)
```

Example 63 (unknown):
```unknown
{'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryVenousEndothelialCells',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselVenousEndothelialCells'}
```

Example 64 (unknown):
```unknown
AnnData object with n_obs × n_vars = 8359 × 1052
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score', 't', 'seg', 'edge', 't_sd', 'milestones', '0->2_lindev_sel'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection', '0->2_rss', 'p_val', 'A', 'fdr', 'st', 'signi', 'cluters'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors', 'draw_graph', 'graph', 'epg', 'pseudotime_list', 'milestones_colors', 'seg_colors', '0->2_lindev_sel_colors', 'stat_assoc_list'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding', 'X_palantir', 'X_umap12', 'X_draw_graph_fr', 'X_R'
    layers: 'fitted'
    obsp: 'connectivities', 'distances'
```

Example 65 (python):
```python
b=adata.uns['stat_assoc_list']
b
#b=list(
#np.savetxt('significantlist.txt', b, delimiter="\n", fmt="%s")
```

Example 66 (python):
```python
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[19], line 1
----> 1 b=adata.uns['stat_assoc_list']
      2 b
      3 #b=list(
      4 #np.savetxt('significantlist.txt', b, delimiter="\n", fmt="%s")

File ~/miniconda3/envs/scFates/lib/python3.8/site-packages/anndata/compat/_overloaded_dict.py:100, in OverloadedDict.__getitem__(self, key)
     98     return self.overloaded[key].get()
     99 else:
--> 100     return self.data[key]

KeyError: 'stat_assoc_list'
```

Example 67 (python):
```python
b=adata.uns['stat_assoc_list']
b=list(b.values())[0]
print(b)
b.to_csv('stat_assoc_list.csv')
```

Example 68 (unknown):
```unknown
{'0':                          p_val         A  fdr  st  signi
 gene_name_multiome-1                                    
 MIR1302-2HG           1.000000  0.000000  1.0   0  False
 FAM138A               1.000000  0.000000  1.0   0  False
 OR4F5                 1.000000  0.000000  1.0   0  False
 AL627309.1            0.143696  0.005061  1.0   0  False
 AL627309.3            0.802828  0.000241  1.0   0  False
 ...                        ...       ...  ...  ..    ...
 AC141272.1            1.000000  0.000000  1.0   0  False
 AC023491.2            1.000000  0.000000  1.0   0  False
 AC007325.1            1.000000  0.000000  1.0   0  False
 AC007325.4            0.948555  0.001124  1.0   0  False
 AC007325.2            0.002238  0.007391  1.0   0  False
 
 [36601 rows x 5 columns]}
```

Example 69 (python):
```python
b=adata.uns['stat_assoc_list']
b=list(b.values())[0]
b
```

Example 70 (unknown):
```unknown
b['signi']=False
b['signi'][[x for x in b.signi if x in Genes]]=True
b['signi'][[x for x in b.signi if x=='FAM138A']]=True
b
```

Example 71 (python):
```python
/tmp/ipykernel_86192/4246633740.py:2: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  b['signi'][[x for x in b.signi if x in Genes]]=True
/tmp/ipykernel_86192/4246633740.py:3: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  b['signi'][[x for x in b.signi if x=='FAM138A']]=True
```

Example 72 (python):
```python
Genes=['COL4A1','COL4A2','H19','COL15A1','ODGFB','ADGRF5','IL32','RGCC','ETS1','KDR','FABP5','ADAMTS9','MYO1B','A2M','ADGRL4','NR2F2','NTS','IL1RL1','ROBO1','RASSF9','KCNIP4','APLNR','FLRT2','TSHZ2','MYRIP','PDE3A','EFNA5','BMP6','SLIT3','SERPINE2','GJA5','SRGN','JAG1','TMEM100','EGFL8','PCSK5','CXCL12','IL33','TSPO','MEOX2','CCL14','APLNR','PRCP','LDB2','FLRT2','COL3A1','CPE','PCDH7','BMPER','HMCN1','CLU','PLXNA4','MEIS2','FBLN2','NRG3','CPXM2','ELN','SULF1','MMP16','FBLN5','DKK2','LTBP4','BGN','LTC4S','MMP2','HEY2','DKK','KCRD12','SULT1E1']
SignificantList=['HES4','VWA1','PRDM16-DT','PRDM16','RERE','CTNNBIP1','RBP7','DHRS3','FBLIM1','MFAP2','ECE1','HSPG2','ID3','CLIC4','STMN1','IFI6','MARCKSL1','GJA4','MACF1','YBX1','RPS8','PIK3R3','EFCAB14','PLPP3','JUN','NFIA','ROR1','JAK1','LEPR','PDE4B','GNG12','NEGR1','SLC44A5','ST6GALNAC3','GIPC2','ADGRL4','ADGRL2','DDAH1','CCN1','TGFBR3','EVI5','FNBP1L','ARHGAP29','CNN3','PALMD','COL11A1','VAV3','FAM102B','RHOC','TSPAN2','CD58','TXNIP','GJA5','C1orf54','S100A11','S100A6','S100A16','ADAM15','EFNA1','FDPS','NES','IFI16','CADM3','ACKR1','DUSP23','TAGLN2','LINC01133','RGS5','PBX1','RCSD1','DNM3','RASAL2','QSOX1','LAMC1','ARPC5','C1orf21','IVNS1ABP','HMCN1','PTGS2','KCNT2','CFH','MIR181A1HG','NR5A2','NAV1','BTG2','PIK3C2B','CD55','CD34','PLXNA2','PTPN14','CAPN2','H3F3A','ITPKB','FAM89A','EGLN1','DISC1','SIPA1L2','LYST','CHRM3','PXDN','RPS7','SOX11','RNF144A','ID2','ASAP2','RHOB','GDF7','ITSN2','PPP1CB','LBH','LTBP1','RASGRP3','CRIM1','ATL2','SRSF7','SLC8A1','EML4','ZFP36L2','PRKCE','EPAS1','CALM2','SPTBN1','RPS27A','CCDC88A','CFAP36','CCDC85A','DYSF','EXOC6B','TMSB10','MAP4K4','IL1R1','SH3RF3','CLASP1','GYPC','NCKAP5','MGAT5','CXCR4','MBD5','ARL5A','FMNL2','PKP4','FIGN','COBLL1','NOSTRIN','ITGA6','ITPRID2','AC007319.1','CALCRL','TFPI','GULP1','COL3A1','COL5A2','HIBCH','GLS','MYO1B','CAVIN2','HECW2','PLCL1','BMPR2','RAPH1','PARD3B','NRP2','EEF1B2','FN1','IGFBP2','IGFBP5','EPHA4','SERPINE2','PTMA','NPPC','DGKD','AGAP1','ACKR3','LRRFIP1','ITPR1','LMCD1','VGLL4','RPL32','FBLN2','RFTN1','THRB','SLC4A7','RBMS3','TGFBR2','RPSA','MYRIP','CTNNB1','SNRK','CLEC3B','LIMD1','MAP4','SEMA3F','GNAI2','HYAL2','RPL29','SEMA3G','ARHGEF3','FHIT','PTPRG','ADAMTS9','MAGI1','FRMD4B','FOXP1','CNTN3','ROBO2','ROBO1','MTRNR2L12','CRYBG3','FILIP1L','ABI3BP','NFKBIZ','ALCAM','CBLB','CD47','PHLDB2','SLC9C1','CCDC80','ZBTB20','LSAMP','AC092691.1','FSTL1','KALRN','HEG1','MGLL','TRH','SLCO2A1','PLSCR4','TM4SF18','TM4SF1','WWTR1','TSC22D2','MBNL1','MECOM','SKIL','PLD1','FNDC3B','NLGN1','NAALADL2','YEATS2','ST6GAL1','HES1','ATP13A3','CYTL1','LDB2','LAP3','KCNIP4','STIM2','PCDH7','KLHL5','RPL9','ATP8A1','OCIAD2','KIT','KDR','IGFBP7','ADGRL3','SULT1B1','SULT1E1','AFF1','SPARCL1','MMRN1','CCSER1','UNC5C','EMCN','PPP3CA','DKK2','COL25A1','CFI','CAMK2D','USP53','FAT4','MGST2','MAML3','INPP4B','SMAD1','SLC10A7','NR3C2','LRBA','RPS3A','GUCY1A1','GRIA2','GASK1B','FNIP2','RAPGEF2','CPE','TLL1','PALLD','SH3RF1','GPM6A','VEGFC','STOX2','PDLIM3','SORBS2','SEMA5A','TRIO','FBXL7','MYO10','MTMR12','EGFLAM','LIFR','GHR','ITGA1','ITGA2','ARL15','ESM1','PLPP1','MAP3K1','PLK2','RAB3C','PDE4D','ADAMTS6','MAST4','MAP1B','ARHGEF28','RPS23','VCAN','MEF2C','MCTP1','LNPEP','ST8SIA4','EFNA5','NREP','EPB41L4A','SEMA6A','LOX','SNCAIP','SLC12A2','FBN2','HINT1','SKP1','SPOCK1','EGR1','ECSCR','PCDH12','SPRY4','ARHGAP26','DPYSL3','ABLIM3','AFAP1L1','CSNK1A1','RPS14','SYNPO','SPARC','GALNT10','SGCD','ADAM19','EBF1','SLIT3','RANBP17','FGF18','NEURL1B','DUSP1','COL23A1','LTC4S','BTNL9','FOXC1','GMDS','SERPINB9','SERPINB6','BMP6','TXNDC5','NEDD9','EDN1','GFOD1','KIF13A','RNF144B','CASC15','CARMIL1','HLA-A','HLA-E','TUBB','IER3','HLA-B','CLIC1','EGFL8','NOTCH4','RPS10','RPL10A','PI16','CLIC5','ADGRF5','LRRC1','DST','EYS','ADGRB3','EEF1A1','AL357507.1','COL12A1','FILIP1','MYO6','PHIP','HMGN3','TENT5A','SNX3','AMD1','REV3L','FYN','MARCKS','MAN1A1','GJA1','NKAIN2','HEY2','NCOA7','RSPO3','AL356124.1','ARHGAP18','CCN2','RPS12','SGK1','PDE7B','ADGRG6','UTRN','SAMD5','AL033504.1','SASH1','PLEKHG1','MTHFD1L','AKAP12','SYNE1','MYCT1','TIAM2','ARID1B','SNX9','SYNJ2','IGF2R','RPS6KA2','AFDN','ACTB','FSCN1','NDUFA4','THSD7A','ARL4A','MEOX2','TSPAN13','AHR','RAPGEF5','AC004540.1','SKAP2','CREB5','AQP1','BMPER','ELMO1','RALA','INHBA','RAMP3','IGFBP3','GRB10','AUTS2','ELN','HSPB1','MAGI2','GNAI1','CD36','SEMA3C','CACNA2D1','CDK14','CDK6','GNG11','COL1A2','PPP1R9A','ARPC1B','SERPINE1','RELN','LAMB1','IMMP2L','DOCK4','MDFIC','CAV2','CAV1','MET','CAPZA2','CADPS2','PODXL','PLXNA4','CALD1','PTN','GIMAP7','GIMAP4','GIMAP1','ESYT2','PRAG1','SOX7','GATA4','DLC1','TUSC3','MTUS1','CSGALNACT1','LOXL2','PPP2R2A','DPYSL2','CLU','HMBOX1','SARAF','LEPROTL1','RBPMS','NRG1','RAB11FIP1','TCIM','SFRP1','PCMTD1','SOX17','XKR4','LYN','TOX','CHD7','CLVS1','PREX2','SULF1','KCNB2','RPL7','HEY1','FABP5','FABP4','MMP16','SLC26A7','RUNX1T1','RPL30','RNF19A','PABPC1','AZIN1','CTHRC1','ZFPM2','OXR1','EXT1','SAMD12','SNTB1','HAS2','MTSS1','PCAT1','PVT1','ASAP1','NDRG1','PTK2','KANK1','IL33','AL583785.1','FREM1','BNC2','ADAMTSL1','RPS6','MLLT3','TEK','B4GALT1','IL11RA','TPM2','CNTNAP3B','PGM5','TRPM3','ALDH1A1','PCSK5','GNA14','TLE1','DAPK1','OMD','AOPEP','COL15A1','SEC61B','KLF4','CTNNAL1','PALM2-AKAP2','RGS3','GSN','STOM','PTGS1','DENND1A','HSPA5','SH2D3C','ENG','SPTAN1','FNBP1','RAPGEF1','COL5A1','EGFL7','DIPK1B','PTGDS','NPDC1','KLF6','NET1','SFMBT2','CELF2','CAMK1D','FRMD4A','FAM107B','VIM','ST8SIA6','MRC1','KIAA1217','MPP7','SVIL','JCAD','MAP3K8','NRP1','PARD3','CCNY','CXCL12','DEPP1','PRKG1','BICC1','ARID5B','JMJD1C','SRGN','PPA1','PALD1','UNC5B','CDH23','VSIR','PSAP','DDIT4','MCU','OIT3','VCL','LRMDA','RPS24','PLAC9','PRXL2A','NRG3','MMRN2','EXOC6','MYOF','PDLIM1','SORBS1','ENTPD1','ENTPD1-AS1','SFRP5','CRTAC1','SH3PXD2A','ADD3','PDCD4','ATRNL1','GRK5','PLEKHA1','HTRA1','CPXM2','CHST15','EBF3','IFITM2','IFITM3','CD151','CTSD','TNNT3','H19','IGF2','HBG2','CAVIN3','SBF2','GALNT18','DKK3','MICAL2','SOX6','RPS13','LGR4','CD59','LMO2','LDLRAD3','LRRC4C','HSD17B12','TSPAN18','TP53I11','MDK','PTPRJ','APLNR','CTNND1','FTH1','NEAT1','MALAT1','LTBP3','CFL1','EFEMP2','CCDC85B','GSTP1','CCND1','ANO1','FCHSD2','SERPINH1','LRRC32','AAMDC','NDUFC2','GAB2','PRCP','DLG2','TMEM135','SESN3','MAML2','PDGFD','SIK2','NCAM1','CADM1','FXYD6','MPZL2','MCAM','THY1','MIR100HG','ESAM','ROBO4','PKNOX2','ETS1','FLI1','CACNA1C','ANO2','VWF','CD9','GAPDH','PTMS','A2M','YBX3','LRP6','EMP1','MGP','PDE3A','LDHB','SOX5','BCAT1','ITPR2','STK38L','PPFIBP1','TMTC1','FGD4','PRICKLE1','DHH','TUBA1B','TUBA1A','FMNL3','LIMA1','ACVRL1','NR4A1','ITGA5','RPS26','MYL6','NACA','LRIG3','MSRB3','IRAK3','PTPRB','PHLDA1','NAV3','TMTC2','RASSF9','NTS','KITLG','BTG1','NUDT4','ELK3','HSP90B1','NUAK1','ALDH2','RPL6','NOS1','PXN','UBC','RPL21','FLT1','MEDAG','POSTN','LHFPL6','FOXO1','RGCC','DGKH','ENOX1','TSC22D1','LRCH1','ITM2B','LPAR6','FNDC3A','DLEU2','PCDH17','AL159156.1','DACH1','KCTD12','EDNRB','POU4F1','ABCC4','DOCK9','FGF14','EFNB2','ARGLU1','FAM155A','COL4A1','COL4A2','ARHGEF7','ATP11A','MCF2L','GAS6','RNASE1','DAD1','STXBP6','NPAS3','CLEC14A','GNG2','NID2','GPR137C','SAMD4A','FBXO34','PELI2','PRKCH','SYNE2','FUT8','GPHN','ACTN1','RGS6','NUMB','LTBP2','PGF','FOS','VASH1','FLRT2','CALM1','RPS6KA5','CCDC88C','FBLN5','MEG3','MEG8','JAG2','CRIP2','CRIP1','SNHG14','FAM189A1','TJP1','MEIS2','THBS1','SRP14','DLL4','SERF2','B2M','SEMA6D','FBN1','CGNL1','MYO1E','RORA','TPM1','HERC1','SMAD6','GLCE','UACA','PEAK1','RPS17','PDE8A','AKAP13','HAPLN3','SLCO3A1','LINC01197','AC012409.2','NR2F2-AS1','NR2F2','MEF2A','CHSY1','RPS2','NPW','SLC9A3R2','IL32','RPS15A','ACSM3','NETO2','CHD9','MMP2','LPCAT2','CDH11','CDH5','NFAT5','GLG1','GABARAPL2','ADAMTS18','PLCG2','CDH13','COTL1','GSE1','CYBA','TUBB3','RFLNB','NXN','ABR','HIC1','ATP2A3','PFN1','RNASEK','TMEM88','RPL26','PIK3R6','NTN1','UBB','SNHG29','SPECC1','RPL23A','SSH2','MYO1D','MMP28','CCL14','RPL23','RPL19','IGFBP4','EIF1','JUP','RAMP2','MEOX1','GRN','NPEPPS','COL1A1','TMEM100','DGKE','CA4','MRC2','TANC2','ACE','ICAM2','PECAM1','PITPNC1','ABCA8','H3F3B','SEC14L1','SOCS3','ACTG1','TBCD','COLEC12','YES1','MYL12A','MYL12B','DLGAP1','EPB41L3','ARHGAP28','PTPRM','LDLRAD4','GATA6','ZNF521','SETBP1','RPL17','TCF4','RNF152','BCL2','CBLN2','NFATC1','GPX4','CIRBP','ABHD17A','GADD45B','TNFAIP8L1','INSR','CD320','KANK3','CDC37','DOCK6','JUNB','NFIX','LYL1','IER2','AC020916.1','KLF2','CPAMD8','PLVAP','BST2','RPL18A','ACTN4','GMFG','ZFP36','PLD3','LTBP4','PCAT19','BCAM','FOSB','SELENOW','CARD8','EMP3','FTL','RPL13A','RPS11','RRAS','MYADM','TCF15','PRND','RASSF2','PLCB1','PLCB4','JAG1','MACROD2','DSTN','RALGAPA2','CD93','CST3','ID1','PROCR','MYL9','TGM2','PPP1R16B','TOX2','SULF2','PREX1','PTGIS','TSHZ2','PMEPA1','GNAS','ATP5F1E','COL9A3','SOX18','MIR99AHG','JAM2','ATP5PF','APP','CYYR1','LINC01695','EVA1C','ITSN1','ETS2','COL18A1','CLDN5','TBX1','COMT','MIF','ADORA2A','SMTN','YWHAH','TIMP3','MYH9','LGALS1','PDGFB','RPL3','TSPO','SHANK3','CD99','MXRA5','FRMPD4','TMSB4X','BMX','NHS','SAT1','IL1RAPL1','DMD','TSPAN7','DIPK2B','TIMP1','RPS4X','XIST','FTX','ITM2A','DIAPH2','NRK','PLS3','DANT2','KLHL13','APLN','FHL1','FGF13','BGN','RPL10','MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4','MT-ND5','MT-CYB']
Genes=list(set(Genes)&set(SignificantList))
g1=scf.pl.trends(adata,
                 highlight_features=Genes,
                 figsize=(4,20),
                 n_features=30,
                 annot='fine_grain',
                 root_milestone="0",
                 milestones=["2"],
                 #branch="Ery",
                 plot_emb=False,ordering="max",return_genes=True)
```

Example 73 (python):
```python
set(adata.obs.fine_grain)
```

Example 74 (unknown):
```unknown
{'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryVenousEndothelialCells',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselVenousEndothelialCells'}
```

Example 75 (python):
```python
ClusterOfInterest='CoronaryCapillaryEndothelialCells'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 76 (unknown):
```unknown
/home/sinhalab/miniconda3/envs/scFates/lib/python3.8/site-packages/scanpy/plotting/_dotplot.py:749: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
  dot_ax.scatter(x, y, **kwds)
```

Example 77 (unknown):
```unknown
AllGenes=['COL4A1','COL4A2','H19','COL15A1','ODGFB','ADGRF5','IL32','RGCC','ETS1','KDR','FABP5','ADAMTS9','MYO1B','A2M','ADGRL4','NR2F2','NTS','IL1RL1','ROBO1','RASSF9','KCNIP4','APLNR','FLRT2','TSHZ2','MYRIP','PDE3A','EFNA5','BMP6','SLIT3','SERPINE2','GJA5','SRGN','JAG1','TMEM100','EGFL8','PCSK5','CXCL12','IL33','TSPO','MEOX2','CCL14','APLNR','PRCP','LDB2','FLRT2','COL3A1','CPE','PCDH7','BMPER','HMCN1','CLU','PLXNA4','MEIS2','FBLN2','NRG3','CPXM2','ELN','SULF1','MMP16','FBLN5','DKK2','LTBP4','BGN','LTC4S','MMP2','HEY2','DKK','KCRD12','SULT1E1']
GeneList=['COL4A1','COL4A2','H19','COL15A1','ADGRF5','IL32','RGCC','ETS1','KDR','FABP5','ADAMTS9','MYO1B','A2M','ADGRL4','NR2F2','NTS','ROBO1','RASSF9','KCNIP4','APLNR','FLRT2','TSHZ2','MYRIP','PDE3A','EFNA5','BMP6','SLIT3','SERPINE2','GJA5','SRGN','JAG1','TMEM100','EGFL8','PCSK5','CXCL12','IL33','TSPO','MEOX2','CCL14','APLNR','PRCP','LDB2','FLRT2','COL3A1','CPE','PCDH7','BMPER','HMCN1','CLU','PLXNA4','MEIS2','FBLN2','NRG3','CPXM2','ELN','SULF1','MMP16','FBLN5','DKK2','LTBP4','BGN','LTC4S','MMP2','HEY2','SULT1E1']
```

Example 78 (python):
```python
metadata=[]
for k in range(0,len(adata)):
    a=adata.obs_names[k]+' , '+str(adata.obs.t[k])+' , '+adata.obs.fine_grain[k]
    metadata.append(a)
    
b=pd.DataFrame(metadata)
b.to_csv('EndothelialTime.csv')
```

Example 79 (python):
```python
print(adata)
adata=adata[:,[x for x in adata.var_names if x in AllGenes]].copy()
print(adata)
```

Example 80 (unknown):
```unknown
AnnData object with n_obs × n_vars = 8359 × 1450
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
AnnData object with n_obs × n_vars = 8359 × 56
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 81 (python):
```python
adata.write('./EndothelialCellsForscFatesVince.h5ad')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Epicardium/PericardiumAndEpicardium.html

**Contents:**
- Subcluster¶

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-09-01 22:02.
```

Example 5 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(297473, 36601)
```

Example 7 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 8 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 9 (python):
```python
#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodeCardiomyocytes':'#854834',
    'AtrioventricularNodeCardiomyocytes':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts1':'#8a6800',
    'MyocardialInterstitialFibroblasts2':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 10 (python):
```python
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_61579/2162444827.py in <module>
     65     'InnateLymphoidCells':'#72497f',
     66 }
---> 67 sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)
     68 
     69 MidGrainPalette={

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in umap(adata, **kwargs)
    657     tl.umap
    658     """
--> 659     return embedding(adata, 'umap', **kwargs)
    660 
    661 

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in embedding(adata, basis, color, gene_symbols, use_raw, sort_order, edges, edges_width, edges_color, neighbors_key, arrows, arrows_kwds, groups, components, layer, projection, scale_factor, color_map, cmap, palette, na_color, na_in_legend, size, frameon, legend_fontsize, legend_fontweight, legend_loc, legend_fontoutline, vmax, vmin, vcenter, norm, add_outline, outline_width, outline_color, ncols, hspace, wspace, title, show, save, ax, return_fig, **kwargs)
    250             groups=groups,
    251         )
--> 252         color_vector, categorical = _color_vector(
    253             adata,
    254             value_to_plot,

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in _color_vector(adata, values_key, values, palette, na_color)
   1267         color_map = {
   1268             k: to_hex(v)
-> 1269             for k, v in _get_palette(adata, values_key, palette=palette).items()
   1270         }
   1271         # If color_map does not have unique values, this can be slow as the

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py in _get_palette(adata, values_key, palette)
   1233     values = pd.Categorical(adata.obs[values_key])
   1234     if palette:
-> 1235         _utils._set_colors_for_categorical_obs(adata, values_key, palette)
   1236     elif color_key not in adata.uns or len(adata.uns[color_key]) < len(
   1237         values.categories

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_utils.py in _set_colors_for_categorical_obs(adata, value_to_plot, palette)
    388         colors_list = [to_hex(x) for x in cmap(np.linspace(0, 1, len(categories)))]
    389     elif isinstance(palette, cabc.Mapping):
--> 390         colors_list = [to_hex(palette[k], keep_alpha=True) for k in categories]
    391     else:
    392         # check if palette is a list and convert it to a cycler, thus

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/scanpy/plotting/_utils.py in <listcomp>(.0)
    388         colors_list = [to_hex(x) for x in cmap(np.linspace(0, 1, len(categories)))]
    389     elif isinstance(palette, cabc.Mapping):
--> 390         colors_list = [to_hex(palette[k], keep_alpha=True) for k in categories]
    391     else:
    392         # check if palette is a list and convert it to a cycler, thus

KeyError: 'AtrioventricularNodePacemakerCells'
```

Example 11 (python):
```python
set(adata.obs.fine_grain)
```

Example 12 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodeCardiomyocytes',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts1',
 'MyocardialInterstitialFibroblasts2',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodeCardiomyocytes',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 13 (python):
```python
set(adata.obs.mid_grain)
```

Example 14 (unknown):
```unknown
{'AtrialCardiomyocytes',
 'BloodVesselEndothelialCells',
 'CardiacConductionSystem',
 'EndocardialCells',
 'EpicardialCells',
 'Fibroblasts',
 'Glia',
 'LymphaticEndothelialCells',
 'LymphoidCells',
 'MuralCells',
 'MyeloidCells',
 'Neurons',
 'PericardialCells',
 'VentricularCardiomyocytes'}
```

Example 15 (python):
```python
set(adata.obs.coarse_grain)
```

Example 16 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Leukocytes',
 'Mesenchymal',
 'Neural'}
```

Example 17 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
adata = adata[adata.obs['fine_grain'].isin(['PericardialCellsFibrous','PericardialCellsParietal','PericardialCellsIntermediate','EpicardiumDerivedCells','MesothelialEpicardialCells'])].copy()
#adata = adata[adata.obs['mid_grain'].isin(['PericardialCells'])].copy()
#adata=adata[adata.obs.mid_grain=='MuralCells',:].copy()
```

Example 18 (unknown):
```unknown
AnnData object with n_obs × n_vars = 20997 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 19 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 20 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:09)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1249
```

Example 21 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    207 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['CKS1B', 'TMPO', 'CKAP2L', 'BUB1', 'ANP32E', 'HJURP', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'CDCA2', 'KIF23', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    483 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 22 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 23 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [01:19<00:00,  1.59s/it, loss=749, v_num=1]
```

Example 24 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['JUND', 'CEBPB', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    236 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBB', 'HBD', 'HBE1', 'HBZ', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    146 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:03)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:05)
```

Example 25 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 26 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 27 (python):
```python
set(adata.obs.fine_grain)
```

Example 28 (unknown):
```unknown
{'EpicardiumDerivedCells',
 'MesothelialEpicardialCells',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal'}
```

Example 29 (python):
```python
ClusterOfInterest='PericardialCells'
sc.tl.rank_genes_groups(adata, 'mid_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 30 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
```

Example 31 (python):
```python
ClusterOfInterest='PericardialCellsParietal'
#sc.tl.rank_genes_groups(adata, 'fine_grain', method='t-test', key_added = "t-test")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',standard_scale='var',cmap='PRGn')
#sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 32 (python):
```python
FineGrainCategoriesOrder=['MesothelialEpicardialCells','EpicardiumDerivedCells','PericardialCellsFibrous','PericardialCellsIntermediate','PericardialCellsParietal']
sc.pl.dotplot(adata,  ['TPM1','ALDH1A2','EZR','CFI','KRT8','KRT18','KRT19','BNC1','MSLN','HAS1','PRG4','COL6A3','COL12A1','POSTN','VCAN','COL16A1','SBSPON','ITLN1','TBX18','KDR','FLRT3','CPB1','VEGFC','MEG3','GPC3','PCOLCE','SPARCL1','ITM2A','SERPINF1','TSHZ2','AUTS2','SETBP1','PID1','PTPRM','PDZRN3','CD9','CD63','CD81','COL1A1','COL1A2','COL3A1'] , var_group_positions=[(0,10),(11,15),(16,18),(19,22),(25,28),(29,34),(35,37)], var_group_labels=['epicardial','pericardial','mesothelial epicardial','epicardium derived','fibrous pericardial','parietal pericardial','exosomal'], var_group_rotation=90,groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn')
```

Example 33 (python):
```python
sc.pl.umap(adata, color='mid_grain')
sc.pl.umap(adata, color='fine_grain')
```

Example 34 (python):
```python
sc.pl.umap(adata, color=['COL2A1','TNMD','THBS4'])
```

Example 35 (python):
```python
#adata.write('./ObjectsToUpload/PericardiumAndEpicardium.h5ad')
```

Example 36 (python):
```python
sc.settings.set_figure_params(dpi=300, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/Visium/Visium_Intagration-Annotation/Visium_integration_no5_plotting_temporal-tissue-annotations.html

**Contents:**
- Import required modules¶
- Prepare functions¶
- Read in anndata¶
- Plot the uncropped section¶
- Add annotation¶
- Plots for figures¶
- HE, whole heart, with scale¶
- Tissue annotations¶

**Examples:**

Example 1 (python):
```python
# this is for the jupyter notebook at JupyterLab
# to make sys.path between the terminal and Jupyter same
import sys

print(sys.path) # especially the path to site-packages are different... so thats why couldn't find correct package...

# remove weird paths...
sys.path = sys.path[:4]+[sys.path[6]]
print(sys.path)
```

Example 2 (unknown):
```unknown
['/nfs/team205/kk18/notebooks/P48_Foetal-heart_Visium/notebooks/notebooks_for_manuscript', '/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python39.zip', '/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9', '/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/lib-dynload', '', '/nfs/users/nfs_k/kk18/.local/lib/python3.9/site-packages', '/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/site-packages']
['/nfs/team205/kk18/notebooks/P48_Foetal-heart_Visium/notebooks/notebooks_for_manuscript', '/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python39.zip', '/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9', '/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/lib-dynload', '/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/site-packages']
```

Example 3 (python):
```python
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

import scanpy as sc
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
# enables correct plotting of text
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42 
import seaborn as sns
import os 
from mpl_toolkits.axes_grid1 import make_axes_locatable

from cell2location.plt import plot_spatial
```

Example 4 (python):
```python
/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
Global seed set to 0
/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/site-packages/umap/distances.py:1063: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  @numba.jit()
/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/site-packages/umap/distances.py:1071: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  @numba.jit()
/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/site-packages/umap/distances.py:1086: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  @numba.jit()
/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/site-packages/umap/umap_.py:660: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  @numba.jit()
```

Example 5 (python):
```python
import session_info
session_info.show()
```

Example 6 (python):
```python
-----
cell2location       0.1.3
matplotlib          3.7.1
mpl_toolkits        NA
numpy               1.24.3
pandas              2.0.1
scanpy              1.9.3
seaborn             0.12.2
session_info        1.0.0
-----
```

Example 7 (python):
```python
PIL                 9.5.0
absl                NA
anndata             0.9.1
asttokens           NA
attr                23.1.0
backcall            0.2.0
certifi             2023.05.07
cffi                1.15.1
charset_normalizer  3.1.0
chex                0.1.7
comm                0.1.3
contextlib2         NA
cycler              0.10.0
cython_runtime      NA
dateutil            2.8.2
debugpy             1.6.7
decorator           5.1.1
defusedxml          0.7.1
docrep              0.3.2
etils               1.2.0
executing           1.2.0
flax                0.6.10
fsspec              2023.5.0
google              NA
h5py                3.8.0
idna                3.4
igraph              0.10.4
importlib_metadata  NA
importlib_resources NA
ipykernel           6.23.0
ipython_genutils    0.2.0
jax                 0.4.9
jaxlib              0.4.9
jedi                0.18.2
joblib              1.2.0
kiwisolver          1.4.4
leidenalg           0.9.1
lightning_fabric    1.9.5
lightning_utilities 0.8.0
llvmlite            0.40.0
ml_collections      NA
ml_dtypes           0.1.0
mpmath              1.3.0
msgpack             1.0.5
mudata              0.2.2
multipledispatch    0.6.0
natsort             8.3.1
numba               0.57.0
numpyro             0.11.0
nvfuser             NA
opt_einsum          v3.3.0
optax               0.1.5
packaging           23.1
parso               0.8.3
patsy               0.5.3
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
platformdirs        3.5.0
prompt_toolkit      3.0.38
psutil              5.9.5
ptyprocess          0.7.0
pure_eval           0.2.2
pycparser           2.21
pydev_ipython       NA
pydevconsole        NA
pydevd              2.9.5
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.15.1
pynndescent         0.5.10
pyparsing           3.0.9
pyro                1.8.4
pytorch_lightning   1.9.5
pytz                2023.3
requests            2.30.0
rich                NA
scipy               1.10.1
scvi                0.20.3
setuptools          66.0.0
six                 1.16.0
sklearn             1.2.2
stack_data          0.6.2
statsmodels         0.14.0
sympy               1.12
texttable           1.6.7
threadpoolctl       3.1.0
toolz               0.12.0
torch               2.0.1+cu117
torchmetrics        0.11.4
tornado             6.3.1
tqdm                4.65.0
traitlets           5.9.0
tree                0.1.8
typing_extensions   NA
umap                0.5.3
urllib3             2.0.2
wcwidth             0.2.6
yaml                6.0
zipp                NA
zmq                 25.0.2
zoneinfo            NA
```

Example 8 (unknown):
```unknown
-----
IPython             8.13.2
jupyter_client      8.2.0
jupyter_core        5.3.0
notebook            6.5.4
-----
Python 3.9.16 (main, Mar  8 2023, 14:00:05) [GCC 11.2.0]
Linux-5.4.0-171-generic-x86_64-with-glibc2.27
-----
Session information updated at 2024-03-21 08:36
```

Example 9 (python):
```python
sc.settings.set_figure_params(dpi=80,dpi_save=300)
```

Example 10 (unknown):
```unknown
figdir = '/nfs/team205/heart/fetal_ms_figures/raw_plots_kk'
```

Example 11 (python):
```python
# This function selects the data for multiple slides from the spatial anndata object.
# Modified `select_slide` in cell2loc for multiple slides

# @param adata: anndata object with multiple spatial experiments
# @param s: list of selected slides
# @param s_col: column in adata.obs listing experiment name for each location

def select_multislide(adata, s, s_col='sample'):

    slides = adata[adata.obs[s_col].isin(s), :]
    s_keys = list(slides.uns['spatial'].keys())
    
    uns_dict = {}
    for ss in s:
        s_spatial=np.array(s_keys)[[ss in k for k in s_keys]][0]
        uns_dict[s_spatial]=slides.uns['spatial'][s_spatial]
    
    slides.uns['spatial'] = uns_dict

    return slides
```

Example 12 (python):
```python
from matplotlib_scalebar.scalebar import ScaleBar
def get_pixel_size_visium(adata, library_id, spot_diameter_real = 55, img='hires'):
    '''
    Utility function to get size of pixels from visium image in AnnData.
    Useful to plot scalebars with matplotlib_scalebar.ScaleBar
    
    Params:
    -------
    - adata: AnnData object storing image info in adata.uns[spatial]
    - library_id: string storing ID for image, must be a key in adata.uns[spatial]
    - spot_diameter_real: numeric storing real diameter of spot, in whatever unit you need 
        (default is 55, for 55 microns of Visium 10X spots)
    - img: which image to use (default: lowres)
    '''

    ## get scale factor converting original pixel positions (adata.obsm['spatial']) to 
    # pixel positions in image
    scalef = adata.uns['spatial'][library_id]['scalefactors']['tissue_{i}_scalef'.format(i=img)]
    ## get spot diameter in image pixels
    spot_diameter_img = adata.uns['spatial'][library_id]['scalefactors']['spot_diameter_fullres'] * scalef
    ## Calculate pixel size
    pixel_size_real = spot_diameter_real/spot_diameter_img
    return(pixel_size_real)
```

Example 13 (python):
```python
adata_ffpe = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-FFPE_foetal_raw.h5ad')

# add abundance to .obs
df = adata_ffpe.obsm['q05_cell_abundance_w_sf'].copy()
## rename columns
df.columns = [x.replace('q05cell_abundance_w_sf_','') for x in df.columns]
adata_ffpe.obs[df.columns]=df.copy()

# set symboßl as var_names
adata_ffpe.var.set_index('SYMBOL',inplace=True)
adata_ffpe
```

Example 14 (unknown):
```unknown
AnnData object with n_obs × n_vars = 19973 × 18085
    obs: 'in_tissue', 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'JC_edit', 'AtrialCardiomyocytesLeft', 'AtrialCardiomyocytesRight', 'VentricularCardiomyocytesLeftCompact', 'VentricularCardiomyocytesRightCompact', 'VentricularCardiomyocytesLeftTrabeculated', 'VentricularCardiomyocytesRightTrabeculated', 'SinoatrialNodeCardiomyocytes', 'AtrioventricularNodeCardiomyocytes', 'VentricularConductionSystemProximal', 'VentricularConductionSystemDistal', 'GreatVesselAdventitialFibroblasts', 'CoronaryVesselAdventitialFibroblasts', 'MyocardialInterstitialFibroblasts1', 'MyocardialInterstitialFibroblasts2', 'Myofibroblasts', 'LymphNodeFibroblasticReticularCells', 'ValveInterstitialCells', 'GreatVesselSmoothMuscleCells', 'CoronarySmoothMuscleCells', 'CoronaryPericytes', 'GreatVesselArterialEndothelialCells', 'GreatVesselVenousEndothelialCells', 'CoronaryArterialEndothelialCells', 'CoronaryVenousEndothelialCells', 'CoronaryCapillaryEndothelialCells', 'EndocardialCells', 'EndocardialCushionCells', 'ValveEndothelialCells', 'LymphaticEndothelialCells', 'MesothelialEpicardialCells', 'EpicardiumDerivedCells', 'NeuronPrecursors', 'ChromaffinCells', 'SympatheticNeurons', 'ParaympatheticNeurons', 'SchwannCellPrecursors', 'SchwannCells', 'MonocytesMPOpos', 'Monocytes', 'MonocyteDerivedCells', 'MacrophagesCX3CR1pos', 'MacrophagesTIMD4pos', 'MacrophagesLYVE1pos', 'MacrophagesATF3pos', 'DendriticCellsType1', 'DendriticCellsMature', 'PlasmacytoidDendriticCells', 'MastCells', 'Megakaryocytes', 'TCellsCD4pos', 'TCellsCD8pos', 'TregsCD4pos', 'ProBCells', 'BCells', 'BCellsMS4A1pos', 'NaturalKillerCells', 'InnateLymphoidCells'
    var: 'gene_ids', 'feature_types', 'genome', 'mt'
    uns: 'spatial'
    obsm: 'MT', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
```

Example 15 (python):
```python
adata_oct = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-OCT_foetal_raw.h5ad')

# add abundance to .obs
df = adata_oct.obsm['q05_cell_abundance_w_sf'].copy()
## rename columns
df.columns = [x.replace('q05cell_abundance_w_sf_','') for x in df.columns]
adata_oct.obs[df.columns]=df.copy()

# set symboßl as var_names
adata_oct.var.set_index('SYMBOL',inplace=True)
adata_oct
```

Example 16 (unknown):
```unknown
AnnData object with n_obs × n_vars = 14261 × 33538
    obs: 'in_tissue', 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'cell2loc-map_group', 'JC_edit', 'sample_for_cell2loc', 'AtrialCardiomyocytesLeft', 'AtrialCardiomyocytesRight', 'VentricularCardiomyocytesLeftCompact', 'VentricularCardiomyocytesRightCompact', 'VentricularCardiomyocytesLeftTrabeculated', 'VentricularCardiomyocytesRightTrabeculated', 'SinoatrialNodeCardiomyocytes', 'AtrioventricularNodeCardiomyocytes', 'VentricularConductionSystemProximal', 'VentricularConductionSystemDistal', 'GreatVesselAdventitialFibroblasts', 'CoronaryVesselAdventitialFibroblasts', 'MyocardialInterstitialFibroblasts1', 'MyocardialInterstitialFibroblasts2', 'Myofibroblasts', 'LymphNodeFibroblasticReticularCells', 'ValveInterstitialCells', 'GreatVesselSmoothMuscleCells', 'CoronarySmoothMuscleCells', 'CoronaryPericytes', 'GreatVesselArterialEndothelialCells', 'GreatVesselVenousEndothelialCells', 'CoronaryArterialEndothelialCells', 'CoronaryVenousEndothelialCells', 'CoronaryCapillaryEndothelialCells', 'EndocardialCells', 'EndocardialCushionCells', 'ValveEndothelialCells', 'LymphaticEndothelialCells', 'MesothelialEpicardialCells', 'EpicardiumDerivedCells', 'NeuronPrecursors', 'ChromaffinCells', 'SympatheticNeurons', 'ParaympatheticNeurons', 'SchwannCellPrecursors', 'SchwannCells', 'MonocytesMPOpos', 'Monocytes', 'MonocyteDerivedCells', 'MacrophagesCX3CR1pos', 'MacrophagesTIMD4pos', 'MacrophagesLYVE1pos', 'MacrophagesATF3pos', 'DendriticCellsType1', 'DendriticCellsMature', 'PlasmacytoidDendriticCells', 'MastCells', 'Megakaryocytes', 'TCellsCD4pos', 'TCellsCD8pos', 'TregsCD4pos', 'ProBCells', 'BCells', 'BCellsMS4A1pos', 'NaturalKillerCells', 'InnateLymphoidCells'
    var: 'gene_ids', 'feature_types', 'genome', 'mt'
    uns: 'spatial'
    obsm: 'MT', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
```

Example 17 (python):
```python
adata_oct_20pcw = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium-OCT-LV_foetal_raw.h5ad')

# add abundance to .obs
df = adata_oct_20pcw.obsm['q05_cell_abundance_w_sf'].copy()
## rename columns
df.columns = [x.replace('q05cell_abundance_w_sf_','') for x in df.columns]
adata_oct_20pcw.obs[df.columns]=df.copy()

# set symboßl as var_names
adata_oct_20pcw.var.set_index('SYMBOL',inplace=True)
adata_oct_20pcw
```

Example 18 (unknown):
```unknown
AnnData object with n_obs × n_vars = 6767 × 33538
    obs: 'in_tissue', 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'sangerID', 'Publication', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'status', 'cell2loc-map_group', 'JC_edit', 'sample_for_cell2loc', 'VentricularCardiomyocytesLeftCompact', 'VentricularCardiomyocytesLeftTrabeculated', 'VentricularConductionSystemProximal', 'VentricularConductionSystemDistal', 'CoronaryVesselAdventitialFibroblasts', 'MyocardialInterstitialFibroblasts1', 'MyocardialInterstitialFibroblasts2', 'Myofibroblasts', 'LymphNodeFibroblasticReticularCells', 'CoronarySmoothMuscleCells', 'CoronaryPericytes', 'CoronaryArterialEndothelialCells', 'CoronaryVenousEndothelialCells', 'CoronaryCapillaryEndothelialCells', 'EndocardialCells', 'LymphaticEndothelialCells', 'MesothelialEpicardialCells', 'EpicardiumDerivedCells', 'NeuronPrecursors', 'ChromaffinCells', 'SympatheticNeurons', 'ParaympatheticNeurons', 'SchwannCellPrecursors', 'SchwannCells', 'MonocytesMPOpos', 'Monocytes', 'MonocyteDerivedCells', 'MacrophagesCX3CR1pos', 'MacrophagesTIMD4pos', 'MacrophagesLYVE1pos', 'MacrophagesATF3pos', 'DendriticCellsType1', 'DendriticCellsMature', 'PlasmacytoidDendriticCells', 'MastCells', 'Megakaryocytes', 'TCellsCD4pos', 'TCellsCD8pos', 'TregsCD4pos', 'ProBCells', 'BCells', 'BCellsMS4A1pos', 'NaturalKillerCells', 'InnateLymphoidCells'
    var: 'gene_ids', 'feature_types', 'genome', 'mt'
    uns: 'spatial'
    obsm: 'MT', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'
```

Example 19 (unknown):
```unknown
slide_ids = {
    '5PCW':'HCAHeartST11605168',
    '7PCW':'HCAHeartST10317185',
    '13PCW':'HCAHeartST11605165',
    '16PCW':'BHF_F_Hea13295830', # FFPE
    '20PCW':'HCAHeartST13162330'
}
```

Example 20 (python):
```python
for week,slide_id in slide_ids.items():
    if week=='16PCW':
        slide = select_multislide(adata_ffpe, [slide_id])
        slide_copy = slide.copy()
        slide.uns['spatial'] = {}
        slide.uns['spatial'][slide_id] = [slide_copy.uns['spatial'][x] for x in slide_copy.uns['spatial'].keys() if slide_id in x][0]
    elif week=='20PCW':
        slide = select_multislide(adata_oct_20pcw, [slide_id])
    else:
        slide = select_multislide(adata_oct, [slide_id])
    
    # get pixel size
    pix_size = get_pixel_size_visium(slide, slide_id, spot_diameter_real = 55)
        
    with mpl.rc_context({#'axes.facecolor':  'black',
                         'figure.figsize': [4.5, 5]}):
        fig, ax = plt.subplots()
        sc.pl.spatial(slide, cmap='RdPu',
                      color=['JC_edit'], 
                      ncols=5, size=0, 
                      img_key='hires', alpha_img=1,wspace=0.3,
                      vmin=0, vmax='p99.5',# palette=palette
                      legend_loc=None,
                      title=f'{week}, {slide_id}, H&E',
                      show=False,ax=ax
                     )
        scalebar = ScaleBar(pix_size, "um", length_fraction=0.25, frameon=False, location='upper right')
        ax.add_artist(scalebar)
        plt.show()
```

Example 21 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 22 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 23 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 24 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 25 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 26 (python):
```python
# read in modify annotations
adata_annot = sc.read_h5ad('/nfs/team205/heart/anndata_objects/Foetal/visium_foetal_healthy-all_raw.h5ad',backed='r')

# modify annotations for matching with factor analysis
annotation_edit_dict = {
   'AV valves':'Valves',
    'Aortic valve':'Valves',
    'Valve apparatus':'Valves',
    'Atrium - Left':'Atrium',
     'Atrium - Right':'Atrium',
    'Ventricle - Compact - Left':'Ventricle - Compact',
    'Ventricle - Compact - Right':'Ventricle - Compact',
    'Ventricle - Trabeculated - Left':'Ventricle - Trabeculated',
    'Ventricle - Trabeculated - Right':'Ventricle - Trabeculated',
}
adata_annot.obs['annotation_final_mod']=adata_annot.obs['annotation_final'].astype('str').copy()
adata_annot.obs.replace({'annotation_final_mod':annotation_edit_dict}, 
                      inplace=True)
adata_annot.obs['annotation_final_mod'] = adata_annot.obs['annotation_final_mod'].astype('category')

# set palette and categorie order
AnnotationPalette={ 
    'Atrium':'#eac075',
        'Ventricle - Compact':'#f1acfa',
     'Ventricle - Trabeculated':'#f09951',
        'SAnode':'#8A2BE2',
        'AVnode':'#062b4a',
    'VCS - Proximal':'#FFFF00',
        'VCS - Distal':'#7FFFD4',
        'Epicardium':'#01ccc8',
        'Endocardium - Atrial':'#DC143C',
        'Endocardium - Ventricular':'#f53527',
        'Endocardial cusion':'#ff7e97',
        'Great vessel':'#ff9b6e',
    'Ductus arteriosus':'#8a6800',
        'Coronary vessel':'#206601',
        'Adventitia - Coronary':'#CAFF70',
     'Adventitia - GV':'#005aa0',
        'AV ring':'#e478ff',
    'Valves':'#3300FF',
    'LN':'#9088ff',
}
adata_annot.obs['annotation_final_mod'] = adata_annot.obs['annotation_final_mod'].astype('category')
adata_annot.obs['annotation_final_mod'] = adata_annot.obs['annotation_final_mod'].cat.reorder_categories(AnnotationPalette.keys())
```

Example 27 (unknown):
```unknown
/nfs/team205/kk18/miniconda3/envs/cell2loc_v013_env/lib/python3.9/site-packages/anndata/_core/anndata.py:1832: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.
  utils.warn_names_duplicates("var")
```

Example 28 (python):
```python
# add
adata_ffpe.obs['annotation_final_mod'] = adata_annot.obs['annotation_final_mod'].reindex(adata_ffpe.obs_names)
adata_oct.obs['annotation_final_mod'] = adata_annot.obs['annotation_final_mod'].reindex(adata_oct.obs_names)
adata_oct_20pcw.obs['annotation_final_mod'] = adata_annot.obs['annotation_final_mod'].reindex(adata_oct_20pcw.obs_names)
```

Example 29 (unknown):
```unknown
slide_ids_sel = {}
for key,value in slide_ids.items():
    if key in ['5PCW','7PCW','16PCW']:
        slide_ids_sel[key] = value
slide_ids_sel
```

Example 30 (unknown):
```unknown
{'5PCW': 'HCAHeartST11605168',
 '7PCW': 'HCAHeartST10317185',
 '16PCW': 'BHF_F_Hea13295830'}
```

Example 31 (unknown):
```unknown
# cropping parameters
cropp_cord_list = {
    '5PCW': [8000,14500,7800,14000],
    '7PCW': [3000,14000,7000,15000],
    '16PCW': [0,17500,500,16500],
}
```

Example 32 (python):
```python
for week,slide_id in slide_ids_sel.items():
    if week=='16PCW':
        slide = select_multislide(adata_ffpe, [slide_id])
        slide_copy = slide.copy()
        slide.uns['spatial'] = {}
        slide.uns['spatial'][slide_id] = [slide_copy.uns['spatial'][x] for x in slide_copy.uns['spatial'].keys() if slide_id in x][0]
    else:
        slide = select_multislide(adata_oct, [slide_id])
    
    # get pixel size
    pix_size = get_pixel_size_visium(slide, slide_id, spot_diameter_real = 55)
        
    crop_coord = cropp_cord_list[week]

    # plot in spatial coordinates
    with mpl.rc_context({#'axes.facecolor':  'black',
                         #'figure.figsize': [4.5, 5]
    }):
        
        fig, ax = plt.subplots()
        sc.pl.spatial(slide, cmap='RdPu',
                      color=['JC_edit'], 
                      ncols=5, size=0, 
                      img_key='hires', alpha_img=1,wspace=0.3,
                      vmin=0, vmax='p99.5',# palette=palette
                      crop_coord = crop_coord,
                      legend_loc=None,
                      title=week,
                      show=False,ax=ax
                     )
        scalebar = ScaleBar(pix_size, "um", length_fraction=0.25, frameon=False, location='upper right')
        ax.add_artist(scalebar)
        plt.savefig(f"{figdir}/visium_temporal_HE_{slide_id}.pdf", bbox_inches="tight",dpi=300)
        plt.show()
```

Example 33 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 34 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 35 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

Example 36 (python):
```python
for week,slide_id in slide_ids_sel.items():
    if week=='16PCW':
        slide = select_multislide(adata_ffpe, [slide_id])
        slide_copy = slide.copy()
        slide.uns['spatial'] = {}
        slide.uns['spatial'][slide_id] = [slide_copy.uns['spatial'][x] for x in slide_copy.uns['spatial'].keys() if slide_id in x][0]
    else:
        slide = select_multislide(adata_oct, [slide_id])
        
    crop_coord = cropp_cord_list[week]

    # plot in spatial coordinates
    with mpl.rc_context({#'axes.facecolor':  'black',
                         #'figure.figsize': [4.5, 5]
    }):
        
        sc.pl.spatial(slide, cmap='RdPu',
                      color=['annotation_final_mod'], 
                      ncols=5, size=1.2, 
                      img_key='hires', alpha_img=0.3,wspace=0.3,
                      vmin=0, vmax='p99.5', palette=AnnotationPalette,
                      crop_coord = crop_coord,
                      legend_loc=None,
                      title=week,
                      show=False
                     )
        plt.savefig(f"{figdir}/visium_temporal_annotations_{slide_id}.pdf", bbox_inches="tight",dpi=300)
```

Example 37 (unknown):
```unknown
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
/tmp/ipykernel_108365/2805736760.py:18: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.
  slides.uns['spatial'] = uns_dict
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/Annotations/NeuralAnnotation.html

**Examples:**

Example 1 (unknown):
```unknown
#Neural Annotation
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2022-12-02 16:35.
```

Example 5 (python):
```python
adata=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(306287, 36601)
```

Example 7 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 8 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 9 (python):
```python
set(adata.obs.coarse_grain)
```

Example 10 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Immune',
 'Mesenchymal',
 'Neural'}
```

Example 11 (python):
```python
adata=adata[adata.obs.coarse_grain=='Neural',:].copy()
adata
```

Example 12 (unknown):
```unknown
AnnData object with n_obs × n_vars = 6002 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 13 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata
```

Example 14 (python):
```python
normalizing counts per cell
    finished (0:00:00)
extracting highly variable genes
    finished (0:00:07)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1571
```

Example 15 (python):
```python
# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()
```

Example 16 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['PCNA', 'FEN1', 'MCM2', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    369 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'ANP32E', 'CDC25C', 'RANGAP1', 'NCAPD2', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'GAS2L3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    724 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 17 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 18 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:24<00:00,  2.04it/s, loss=797, v_num=1]
```

Example 19 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 20 (python):
```python
# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()
sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
#sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
```

Example 21 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['FOSB', 'JUN', 'JUND', 'SOCS3', 'CEBPB', 'ATF3', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    390 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    345 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:01)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:04)
```

Example 22 (python):
```python
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','hb2_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)
```

Example 23 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 24 (python):
```python
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 25 (python):
```python
sc.pl.umap(adata, color='previous_fine_grain')
```

Example 26 (python):
```python
#this block is to see where the cells over a certain threshold with TNNT2 expression lies in the UMAP
#enter what gene to set threshold for
#when running this box for the first time, comment the starting with 'del'
#then uncomment it for the other ones --- !!!

CellName='Cardio_toremove'
gene='TTN'
exp_thresh=2
gene_pos=adata.var_names.get_loc(gene)
adata_sel = adata[adata.X[:,gene_pos]>exp_thresh].copy()

l=adata_sel.obs_names
set(l).intersection(adata.obs_names)
print(len(l))

#del adata.obs[CellName]
adata.obs.loc[set(l).intersection(adata.obs_names),CellName]='Yes'
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=[CellName], groups='Yes',size=10, wspace=0.45, legend_fontsize=5, legend_loc='on data',frameon=False)

print(adata)
adata= adata[adata.X[:,gene_pos]<exp_thresh].copy()
print(adata)
```

Example 27 (unknown):
```unknown
... storing 'Cardio_toremove' as categorical
```

Example 28 (unknown):
```unknown
AnnData object with n_obs × n_vars = 6002 × 1571
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
AnnData object with n_obs × n_vars = 5832 × 1571
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 29 (python):
```python
#this block is to see where the cells over a certain threshold with TNNT2 expression lies in the UMAP
#enter what gene to set threshold for
#when running this box for the first time, comment the starting with 'del'
#then uncomment it for the other ones --- !!!

CellName='Mesenchymal_toremove'
gene='COL6A3'
exp_thresh=1.5
gene_pos=adata.var_names.get_loc(gene)
adata_sel = adata[adata.X[:,gene_pos]>exp_thresh].copy()

l=adata_sel.obs_names
set(l).intersection(adata.obs_names)
print(len(l))

#del adata.obs[CellName]
adata.obs.loc[set(l).intersection(adata.obs_names),CellName]='Yes'
sc.settings.set_figure_params(dpi=200, facecolor='white', color_map = 'RdPu',)
sc.pl.umap(adata, color=[CellName], groups='Yes',size=10, wspace=0.45, legend_fontsize=5, legend_loc='on data',frameon=False)

print(adata)
adata= adata[adata.X[:,gene_pos]<exp_thresh].copy()
print(adata)
```

Example 30 (unknown):
```unknown
... storing 'Mesenchymal_toremove' as categorical
```

Example 31 (unknown):
```unknown
AnnData object with n_obs × n_vars = 5832 × 1571
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove', 'Mesenchymal_toremove'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors', 'Mesenchymal_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
AnnData object with n_obs × n_vars = 5670 × 1571
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove', 'Mesenchymal_toremove'
    var: 'gene_name_scRNA-0', 'gene_id', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors', 'Mesenchymal_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    layers: 'counts'
    obsp: 'connectivities', 'distances'
```

Example 32 (python):
```python
#Re-run analyis with cardio-mesenchymal removed

adata_raw=sc.read('./Objects/20221130RNA_foetal_post-scVI_raw_ExtracardiacRemoved.h5ad')

print(adata_raw)
# constructing new anndata with maintaining .obs, .obsm, .obsp, .uns
# overwriting adata_raw
adata_raw=anndata.AnnData(X=adata_raw[adata.obs_names,:].X,
                      obs=adata.obs, # from annotated or subsetted data
                      var=adata_raw.var,
                      obsm=adata.obsm, # from annotated or subsetted data
                      obsp=adata.obsp, # from annotated or subsetted data
                    uns=adata.uns # from annotated or subsetted data
                               )

adata=adata_raw.copy()
print(adata)
```

Example 33 (unknown):
```unknown
AnnData object with n_obs × n_vars = 306287 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
AnnData object with n_obs × n_vars = 5670 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'donor_type', 'region', 'region_finest', 'age', 'gender', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'flushed', 'scrublet_score', 'scrublet_leiden', 'cluster_scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'batch_key', '_scvi_batch', '_scvi_labels', 'previous_coarse_grain', 'previous_mid_grain', 'previous_fine_grain', 'leiden_scVI', 'FACSgate', 'S_score', 'G2M_score', 'phase', 'stress_score', 'hb1_score', 'hb2_score', 'leiden', 'coarse_grain', 'sex', 'Cardio_toremove', 'Mesenchymal_toremove'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'dendrogram_leiden', 'donor_colors', 'gender_colors', 'hvg', 'kit_10x_colors', 'leiden', 'leiden_colors', 'modality_colors', 'neighbors', 'phase_colors', 'rank_genes_groups', 'region_colors', 'sex_colors', 'umap', 'log1p', 'age_colors', 'previous_fine_grain_colors', 'Cardio_toremove_colors', 'Mesenchymal_toremove_colors'
    obsm: 'X_pca', 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 34 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')
sc.tl.score_genes(adata, hb_genes2, score_name='hb2_score')
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)

sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','hb2_score','phase'], ncols=5,)
sc.pl.umap(adata, color=['donor','sex','age','region','phase','cell_or_nuclei','modality','kit_10x','FACSgate'],wspace=0.8,ncols=5)

Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','COL6A3','FBLN1','PCOLCE','LRRC17','EMCN','ECSCR','PECAM1','CDH5', 'LAPTM5','PTPRC','LCP1','CD53','PHOX2B','NRXN1','STMN2','GRIK2']
sc.pl.umap(adata, color=Genes)
```

Example 35 (python):
```python
normalizing counts per cell
    finished (0:00:00)
WARNING: adata.X seems to be already log-transformed.
extracting highly variable genes
    finished (0:00:07)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
1518
```

Example 36 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['PCNA', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'PRIM1', 'RFC2', 'RPA2', 'NASP', 'GMNN', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'POLA1', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    410 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['TMPO', 'HJURP', 'CDC25C', 'RANGAP1', 'NCAPD2', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'G2E3', 'GAS2L3', 'CBX5']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    772 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 37 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 38 (unknown):
```unknown
Epoch 50/50: 100%|███████████| 50/50 [00:22<00:00,  2.21it/s, loss=778, v_num=1]
```

Example 39 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['FOSB', 'JUN', 'JUND', 'SOCS3', 'ATF3', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'BTG1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    491 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    293 total control genes are used. (0:00:00)
computing score 'hb2_score'
WARNING: genes are not in var_names and ignored: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'TRIM58', 'HMBS']
    finished: added
    'hb2_score', score of gene set (adata.obs).
    49 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:00)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:03)
```

Example 40 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 41 (unknown):
```unknown
<Figure size 800x800 with 0 Axes>
```

Example 42 (python):
```python
sc.pl.umap(adata, color='previous_fine_grain')
```

Example 43 (python):
```python
sc.pl.umap(adata, color='region')
```

Example 44 (python):
```python
sc.tl.leiden(adata, resolution=0.15, key_added='leiden')
sc.pl.umap(adata, color='leiden',legend_loc='on data')
```

Example 45 (python):
```python
running Leiden clustering
    finished: found 5 clusters and added
    'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
```

Example 46 (python):
```python
Genes1=['IL1RAPL2','PHOX2B','TBX3','PCSK2','PRKG1']
Genes2=['NR2F2','RELN','GASK1B','ITIH5','LAMA2','MBP','COL14A1','MATN2','ITGB8','GJA1']
sc.pl.umap(adata, color=Genes1)
sc.pl.umap(adata, color=Genes2)
```

Example 47 (python):
```python
sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
ClusterOfInterest='1'
#sc.tl.rank_genes_groups(adata, 'leiden', method='t-test', key_added = "wilcoxon")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:100]]
sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 48 (python):
```python
sc.pl.umap(adata, color='PLLP')
```

Example 49 (python):
```python
ClusterOfInterest='0'
#sc.tl.rank_genes_groups(adata, 'leiden', method='t-test', key_added = "wilcoxon")
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:100]]
sc.pl.umap(adata, color=DEGenesForCluster)
```

Example 50 (python):
```python
sc.tl.rank_genes_groups(adata, 'leiden', groups=['0'], reference='1', method='wilcoxon')
sc.pl.rank_genes_groups(adata, groups=['0'], n_genes=20)
```

Example 51 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:02)
```

Example 52 (python):
```python
#adata.write('./Objects/Neural.h5ad')
##adata=sc.read('./Objects/Neural.h5ad')
```

Example 53 (python):
```python
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
sc.tl.dendrogram(adata, groupby='leiden')
#sc.pl.dendrogram(adata,groupby='leiden')
sc.pl.rank_genes_groups_matrixplot(adata, groupby='leiden', standard_scale='var')
```

Example 54 (python):
```python
ranking genes
    finished: added to `.uns['rank_genes_groups']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
    using 'X_pca' with n_pcs = 50
Storing dendrogram info using `.uns['dendrogram_leiden']`
```

---

## Notebook

**URL:** http://127.0.0.1:9020/notebooks_html/Fig1_General_processing/RNA/scnRNA_Integration-Annotation/DE compendium.html

**Contents:**
- Subcluster¶

**Examples:**

Example 1 (unknown):
```unknown
#Added the keys for age and sex
```

Example 2 (python):
```python
# Import packages, initial settings

import numpy as np
import matplotlib.pyplot as plt
import scanpy as sc
import pandas as pd
import anndata
import scrublet as scr
import seaborn as sns
import magic
import pybiomart
import six
import sys
sys.modules['sklearn.externals.six'] = six
import scanorama
import harmonypy
import bbknn
import gseapy
from gseapy.plot import barplot, dotplot
import scvelo as scv
import scvi

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

sc.settings.verbosity = 3  # verbosity: errors (0), warnings (1), info (2), hints (3)

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list(name='gene_cmap', colors=['lightgrey', 'thistle', 'red', 'darkred']) 

sc.settings.set_figure_params(dpi=80, color_map='viridis', vector_friendly=False,  dpi_save=300, facecolor='white')
sc.logging.print_version_and_date()
#sc.logging.print_versions()
```

Example 3 (unknown):
```unknown
Global seed set to 0
```

Example 4 (unknown):
```unknown
Running Scanpy 1.8.1, on 2023-05-16 17:38.
```

Example 5 (python):
```python
adata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
print(adata.shape)
```

Example 6 (unknown):
```unknown
(297473, 36601)
```

Example 7 (python):
```python
cell_cycle_genes = ['MCM5','PCNA','TYMS','FEN1','MCM2','MCM4','RRM1','UNG','GINS2','MCM6','CDCA7','DTL','PRIM1','UHRF1','MLF1IP','HELLS','RFC2','RPA2','NASP','RAD51AP1','GMNN','WDR76','SLBP','CCNE2','UBR7','POLD3','MSH2','ATAD2','RAD51','RRM2','CDC45','CDC6','EXO1','TIPIN','DSCC1','BLM','CASP8AP2','USP1','CLSPN','POLA1','CHAF1B','BRIP1','E2F8','HMGB2','CDK1','NUSAP1','UBE2C','BIRC5','TPX2','TOP2A','NDC80','CKS2','NUF2','CKS1B','MKI67','TMPO','CENPF','TACC3','FAM64A','SMC4','CCNB2','CKAP2L','CKAP2','AURKB','BUB1','KIF11','ANP32E','TUBB4B','GTSE1','KIF20B','HJURP','CDCA3','HN1','CDC20','TTK','CDC25C','KIF2C','RANGAP1','NCAPD2','DLGAP5','CDCA2','CDCA8','ECT2','KIF23','HMMR','AURKA','PSRC1','ANLN','LBR','CKAP5','CENPE','CTCF','NEK2','G2E3','GAS2L3','CBX5','CENPA']
s_genes = cell_cycle_genes[:43]
s_genes = [x for x in s_genes if x in adata.var_names]
print('S genes:', s_genes, '\n')
g2m_genes = cell_cycle_genes[43:]
g2m_genes = [x for x in g2m_genes if x in adata.var_names]
print('G2 genes:', g2m_genes, '\n')
cell_cycle_genes = [x for x in cell_cycle_genes if x in adata.var_names]

hb_genes1 = ['HBB','HBD','HBG1','HBG2','HBE1','HBZ','HBM','HBA2','HBA1', 'HBQ1']
hb_genes1 = [x for x in hb_genes1 if x in adata.var_names]
print('Hemoglobin genes set 1:', hb_genes1, '\n')

hb_genes2 = ['AHSP','GYPA','RHAG','GFI1B','KEL','EPB42','ALAS2','TSPO2','GYPB','GYPE','SPTA1','RHCE','KLF1','RHD','SLC4A1','SNX22','SQSTM1','SOD1','FTH1','MAP1LC3B','SLC25A37','TRIM58','HMBS']
hb_genes2 = [x for x in hb_genes2 if x in adata.var_names]
print('Hemoglobin genes set 2:', hb_genes2, '\n')

mito_genes=['MT-ND1','MT-ND2','MT-CO1','MT-CO2','MT-ATP8','MT-ATP6','MT-CO3','MT-ND3','MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB']
mito_genes = [x for x in mito_genes if x in adata.var_names]
print('Mitochondrial genes:', mito_genes, '\n')

ribo_genes = ['RPLP0','RPLP1','RPLP2','RPL3','RPL3L','RPL4','RPL5','RPL6','RPL7','RPL7A','RPL7L1','RPL8','RPL9','RPL10','RPL10A','RPL10L','RPL11','RPL12','RPL13','RPL13A','RPL14','RPL15','RPL17','RPL18','RPL18A','RPL19','RPL21','RPL22','RPL22L1','RPL23','RPL23A','RPL24','RPL26','RPL26L1','RPL27','RPL27A','RPL28','RPL29','RPL30','RPL31','RPL32','RPL34','RPL35','RPL35A','RPL36','RPL36A','RPL36AL','RPL37','RPL37A','RPL38','RPL39','RPL39L','UBA52','RPL41','RPSA','RPS2','RPS3','RPS3A','RPS4X','RPS4Y1','RPS4Y2','RPS5','RPS6','RPS7','RPS8','RPS9','RPS10','RPS11','RPS12','RPS13','RPS14','RPS15','RPS15A','RPS16','RPS17','RPS18','RPS19','RPS20','RPS21','RPS23','RPS24','RPS25','RPS26','RPS27','RPS27A','RPS27L','RPS28','RPS29','FAU']
ribo_genes = [x for x in ribo_genes if x in adata.var_names]
print('Ribo genes:', ribo_genes, '\n')

stress_genes=['FOS','FOSB','JUN','JUNB','JUND','ZFP36','SOCS3','CEBPD','CEBPB','ATF3','EGR1','HSPA1A','HSPA1B','HSP90AA1','HSP90AB1','HSPA8','HSPB1','HSPE1','IER3','IER2','BTG1','BTG2','DUSP1']
stress_genes = [x for x in stress_genes if x in adata.var_names]
print('Tissue dissociation stress associated genes:', stress_genes, '\n')

FoxProteins=['FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1']
chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']
MembraneProteins1=['AADAT','AAK1','ABCA12','ABCA7','ABCB1','ABCB11','ABCB4','ABCB6','ABCC1','ABCC3','ABCC4','ABCC5','ABCC6','ABCG2','ABHD3','ABI1','ABLIM3','AC004691.2','AC004922.1','AC005324.3','AC005726.1','AC008403.1','AC138696.1','ACIN1','ACKR3','ACLY','ACOT13','ACOT9','ACTN1','ACTR10','ACTR6','ADA','ADAM10','ADAM12','ADAM22','ADAM28','ADAM33','ADAMTS1','ADAMTS2','ADAMTSL4','ADAP1','ADCK5','ADD1','ADD2','ADGRB2','ADGRD1','ADGRG2','ADGRG7','ADGRL2','ADH1A','ADH1B','ADH1C','ADH7','ADK','ADORA1','ADRA1B','ADRM1','ADSS','AFAP1L2','AFDN','AFG1L','AGER','AGRN','AHNAK','AHNAK2','AIFM2','AKAP10','AKAP11','AKAP12','AKR1B10','AKR1B15','AL132780.3','AL139300.1','AL355315.1','AL358113.1','AL645922.1','ALDH3A1','ALK','ALOX15B','ALOXE3','ALPI','ALPP','ALPPL2','ALS2CR12','AMACR','AMDHD1','AMER1','AMER2','AMIGO2','AMOT','AMOTL1','AMOTL2','AMPH','ANK2','ANK3','ANKEF1','ANKFN1','ANKIB1','ANKLE2','ANKRA2','ANKRD13A','ANKRD35','ANKRD42','ANKRD45','ANKS1B','ANO1','ANO10','ANO2','ANO6','ANPEP','ANXA1','ANXA13','ANXA2','ANXA3','AP2M1','APBB1','APBB1IP','APC','APLP1','APMAP','APOC3','APOD','APOLD1','AQP1','AQP10','AQP3','AQP4','AQP5','ARAP1','ARF1','ARHGAP18','ARHGAP19','ARHGAP21','ARHGAP22','ARHGAP23','ARHGAP24','ARHGAP28','ARHGAP29','ARHGAP33','ARHGAP36','ARHGAP40','ARHGAP9','ARHGDIG','ARHGEF1','ARHGEF11','ARHGEF12','ARHGEF15','ARHGEF26','ARHGEF28','ARHGEF40','ARHGEF5','ARID2','ARID4A','ARID5B','ARL13A','ARL15','ARL4C','ARMC12','ARMCX5','ARPC1A','ARPC5','ARRB2','ARRDC4','ARVCF','ASAP1','ASB5','ASGR1','ASGR2','ASH2L','ASIC1','ASIC4','ASPM','ASPSCR1','ATG13','ATG3','ATG7','ATIC','ATOX1','ATP10D','ATP12A','ATP13A3','ATP1B3','ATP23','ATP2B1','ATP2B4','ATP2C2','ATP6V0A2','ATP6V1H','ATP8A2','ATP8B1','ATXN10','ATXN3','ATXN7L3','AVEN','AVPI1','AXIN2','AXL','B2M','B3GALT2','BACE1','BAG3','BAIAP2','BAIAP2L1','BANK1','BASP1','BBOF1','BCAR1','BCAR3','BCL2L12','BCORL1','BCR','BDKRB2','BEND6','BFSP1','BFSP2','BICD2','BIN2','BLNK','BLVRB','BMPR2','BMX','BOC','BOLL','BORCS5','BORCS8-MEF2B','BRK1','BRPF1','BRSK1','BSDC1','BST2','BTK','BTN2A1','BTRC','BUB1B-PAK6','BVES','BZW2','C10orf90','C11orf42','C11orf52','C12orf73','C12orf76','C14orf37','C14orf93','C16orf74','C17orf58','C17orf62','C18orf21','C19orf33','C19orf38','C19orf48','C19orf71','C1orf116','C1orf189','C1orf35','C1orf54','C1orf68','C1orf74','C1QBP','C2orf72','C3orf14','C3orf20','C3orf38','C4orf19','C4orf22','C7orf43','C8orf33','C8orf37','C9orf153','C9orf3','CA14','CA9','CABLES2','CACNA1E','CACNG4','CADM1','CALCRL','CALD1','CALML5','CALN1','CAMK2A','CAMK2B','CAMK2D','CAMK2G','CAP2','CAPS','CASKIN2','CASP4','CAST','CAV3','CAVIN1','CAVIN2','CAVIN3','CAVIN4','CBWD1','CBWD2','CBWD3','CBWD5','CBWD6','CC2D1A','CCBE1','CCDC107','CCDC112','CCDC115','CCDC124','CCDC136','CCDC144NL','CCDC15','CCDC154','CCDC170','CCDC24','CCDC28A','CCDC59','CCDC62','CCDC66','CCDC69','CCDC8','CCDC83','CCDC85C','CCDC93','CCDC97','CCNT2','CCNYL1','CCR3','CCR4','CCT3','CD109','CD163','CD164L2','CD200R1','CD226','CD248','CD274','CD2AP','CD300A','CD300LB','CD33','CD34','CD37','CD38','CD3E','CD3G','CD4','CD44','CD46','CD47','CD48','CD79B','CD81','CD84','CD86','CD8A','CD8B','CD9','CD93','CD99L2','CDAN1','CDC42EP1','CDC42EP3','CDC42EP4','CDC42SE1','CDCA4','CDH1','CDH13','CDH15','CDH17','CDH2','CDH26','CDH3','CDH4','CDH5','CDH6','CDH8','CDIPT','CDK16','CDK5','CDK5RAP2','CDK7','CDRT15','CDV3','CEACAM5','CELSR1','CENPJ','CEP162','CEP295','CEP55','CEP57L1','CEP89','CERCAM','CFAP157','CFAP206','CFAP58','CFAP65','CFB','CFL2','CFLAR','CGN','CGNL1','CHCHD7','CHIC2','CHMP2A','CHRM3','CHRNA1','CHRNA5','CHRNB4','CHRND','CIB1','CIB3','CIP2A','CKAP5','CLCA2','CLCA4','CLCN5','CLCN6','CLDN11','CLDN18','CLDN2','CLDN23','CLDN3','CLDN4','CLDN7','CLDN9','CLEC2A','CLEC4F','CLEC5A','CLECL1','CLIC2','CLIC5','CLTB','CLUL1','CMTM4','CMTM7','CMTR2','CMYA5','CNGA1','CNKSR2','CNNM1','CNNM4','CNP','CNR1','CNTD1','COBL','COBLL1','COG3','COL16A1','COL17A1','COL4A5','COL6A2','COLEC12','COLQ','COMMD4','COMTD1','COPRS','COQ7','CORIN','CORO1B','CORO2A','CORO2B','COX6B2','CPEB3','CPPED1','CPZ','CRB3','CREB5','CRIP1','CRIP2','CRK','CRLF3','CROCC','CRTC1','CRYAB','CRYBG3','CRYL1','CSDE1','CSF1','CSF1R','CSPG4','CST6','CTNNA1','CTNNB1','CTNNBIP1','CTNND1','CTNND2','CTSF','CTSV','CTTN','CTXN1','CUEDC1','CUTA','CX3CL1','CX3CR1','CXADR','CXCR2','CYB5D2','CYBRD1','CYFIP2','CYP20A1','CYP24A1','CYTH2','CYTH4','DAAM1','DAB2','DAG1','DAGLB','DAW1','DBN1','DCAF13','DCAF16','DCBLD2','DCHS1','DCHS2','DCP2','DCT','DCTN6','DCUN1D2','DDAH1','DDB2','DDIAS','DDIT4L','DDR1','DDR2','DDX58','DDX60L','DENND6B','DFFA','DGKG','DGKH','DHDDS','DHPS','DHRS7B','DIAPH1','DIAPH3','DIO2','DIS3L','DLG1','DLG2','DLG5','DLGAP3','DLL3','DMWD','DNAAF1','DNAAF4','DNAH17','DNAJA4','DNAJB13','DNAJB4','DNAJC18','DNAJC5','DNAJC6','DNAJC9','DOC2A','DOCK4','DOK3','DONSON','DPEP1','DPH1','DPPA5','DPYSL2','DQX1','DRD1','DRP2','DSC3','DSEL','DSG2','DSP','DTNA','DUS1L','DUSP15','DXO','DYSF','ECSCR','EDA2R','EDNRA','EDNRB','EEF1AKMT1','EEF2','EFCAB1','EFCAB11','EFCAB2','EFCAB7','EFHC2','EFNB1','EFR3A','EFR3B','EGFR','EHBP1','EHD1','EHD2','EHD3','EHD4','EIF2B2','EIF5','EIF5B','ELFN1','ELMO3','ELN','ELOC','EMP3','ENAH','ENC1','ENG','ENKD1','ENO1','ENO2','ENO3','ENOX1','ENOX2','EPB41','EPB41L1','EPB41L2','EPB41L3','EPB41L4A','EPB41L4B','EPB41L5','EPCAM','EPHA2','EPHA3','EPHB1','EPHB2','EPN1','EPOR','EPS8L2','ERAP1','ERBB2','ERBB3','ERBIN','ERC1','ERCC4','ERMN','ESCO2','ETNK1','ETS2','EVA1A','EVI2B','EXOC1','EXOC3L1','EXOC7','EZR','F11R','F2RL1','F2RL3','FAAP20','FABP2','FABP3','FABP5','FAIM','FAM126A','FAM126B','FAM129A','FAM129B','FAM13A','FAM163B','FAM171A1','FAM193A','FAM205A','FAM210B','FAM222A','FAM45A','FAM47E','FAM47E-STBD1','FAM72A','FAM72B','FAM72C','FAM72D','FANCG','FAS','FASN','FBLIM1','FBLN2','FBLN5','FBLN7','FBP2','FBRSL1','FBXL2','FBXO16','FBXO38','FBXO41','FBXW11','FCAR','FCGBP','FCGR1A','FCGR1B','FCGR2A','FCHSD2','FFAR4','FGD1','FGD5','FGFR2','FGR','FHIT','FHL1','FIBCD1','FIGN','FILIP1','FILIP1L','FKBP2','FLAD1','FLCN','FLNA','FLNB','FLNC','FLOT1','FLOT2','FLRT3','FLT1','FLT4','FLVCR1','FMN2','FMNL2','FMNL3','FNBP1','FOXA2','FOXN3','FP565260.3','FRMD3','FRMD7','FRMD8','FRS2','FSCN1','FTCD','FUT2','FXYD3','FYB1','FYN','FZD1','FZD2','FZD4','FZD6','GAB1','GAB2','GABRA1','GABRA2','GABRA3','GABRA5','GABRG1','GAD1','GADL1','GAGE1','GAGE10','GAGE12C','GAGE12D','GAGE12E','GAGE12F','GAGE12G','GAGE12H','GAGE12J','GAGE13','GAGE2A','GAGE2E','GALNT10','GALR1','GAP43','GAPDH','GAPT','GAPVD1','GAS2','GAS2L1','GAS7','GAS8','GBP4','GCA','GCC1','GCLM','GCSAML-AS1','GFI1B','GFOD1','GFRA3','GHR','GID8','GINM1','GIPC1','GJA1','GJB3','GJB4','GJB6','GJB7','GJC1','GJC2','GLO1','GLP2R','GLRX','GLUL','GMIP','GNAI2','GNAQ','GNAS','GNB1','GNB2','GNB3','GNB4','GNG2','GP9','GPAT3','GPATCH1','GPBP1','GPBP1L1','GPC1','GPC3','GPC4','GPI','GPR1','GPR142','GPR156','GPR157','GPR160','GPR173','GPR20','GPR27','GPR50','GPR63','GPRC5A','GPRIN1','GPRIN2','GPX8','GRAMD1A','GRAMD1B','GRAMD1C','GRAP2','GRB7','GRID2IP','GRIK5','GRK3','GRK5','GRPR','GSDMA','GTF2F1','GTSE1','GUCA1A','GYPA','GYPC','HAPLN3','HARBI1','HAS1','HAUS4','HAUS7','HCAR2','HCAR3','HCFC2','HCK','HCLS1','HCST','HDAC8','HEG1','HELZ','HENMT1','HERC2','HERPUD1','HFE','HIF1A','HIF3A','HINT1','HIP1R','HLA-A','HLA-DPB1','HMGCS1','HMOX1','HOMER3','HOXC5','HOXD4','HPS3','HRASLS5','HRH1','HS6ST3','HSH2D','HSPB1','HSPG2','HTR1B','HTR7','HTRA1','HUNK','HYDIN','HYI','HYLS1','ICAM1','ICAM2','ICOS','ICOSLG','IFFO2','IFIT5','IFNGR1','IFRD1','IFT122','IGFL2','IGSF11','IGSF23','IKZF5','IL10RA','IL12RB1','IL12RB2','IL13','IL13RA2','IL16','IL17RB','IL1R1','IL1RL1','IL21R','IL4R','IL6ST','IL7R','ILDR2','ILK','INPP5A','INSR','INTS12','IP6K2','IPCEF1','IQGAP1','IQGAP2','IREB2','IRF2','IRS1','ISLR','ITGA2B','ITGA3','ITGA4','ITGA7','ITGA8','ITGA9','ITGB1','ITGB2','ITGB3','ITGB4','ITGB5','ITGB6','ITGB7','ITGB8','ITK','ITM2A','ITPKA','ITSN1','ITSN2','IYD','JAG1','JAK2','JAK3','JAM2','JAML','JCAD','JMJD4','JPT2','JUP','KANK1','KANK3','KANSL2','KARS','KATNB1','KCNAB1','KCNB2','KCNH8','KCNJ15','KCNK13','KCNK17','KCNK6','KCNK7','KCNK9','KCNN2','KCNS3','KCNU1','KDF1','KDR','KEL','KIAA0556','KIAA0895','KIAA1324','KIAA1522','KIAA1958','KIF17','KIF19','KIF21A','KIF21B','KIF26A','KIF26B','KISS1R','KIT','KLC1','KLC2','KLF9','KLHDC7B','KLHL41','KLHL6','KLHL7','KLK7','KLRC1','KLRC2','KLRF1','KLRK1','KMT2D','KNDC1','KNSTRN','KNTC1','KPTN','KRT75','KRT77','KRTAP25-1','L1CAM','L3MBTL1','LAIR1','LAMA4','LAMC1','LAMP2','LAMTOR1','LAPTM4A','LASP1','LAT','LAT2','LAX1','LCP1','LCTL','LDB2','LDLRAD3','LENG1','LGALS3','LGALS4','LGALS8','LGR6','LHFPL2','LHX6','LIMA1','LINGO1','LIPJ','LMCD1','LMOD2','LMTK2','LMTK3','LNX1','LNX2','LONRF1','LONRF3','LOXHD1','LPAR1','LPAR3','LPAR4','LPIN1','LPIN2','LRCH2','LRP11','LRP12','LRRC15','LRRC26','LRRC34','LRRC45','LRRC69','LRRC7','LRRC9','LRRFIP2','LRRIQ3','LSMEM2','LSR','LTB4R2','LUZP2','LY6K','LYN','LYPD1','LYST','LZTS1','LZTS2','MACF1','MADD','MAGI1','MAGI3','MAMDC2','MAP1S','MAP2','MAP2K1','MAP2K4','MAP2K7','MAP3K12','MAP3K21','MAP3K6','MAP3K7','MAP4','MAP4K1','MAP4K5','MAP6','MAPK15','MAPK8IP1','MAPT','MARCH10','MARCH7','MARCKS','MARK2','MARVELD2','MAS1L','MAT2B','MBP','MC5R','MCAM','MCEMP1','MCF2L2','MCMBP','MCTS1','MDGA1','ME1','MEF2B','MEIOC','MEPCE','MERTK','MET','METAP1','METAP2','METTL15','METTL25','METTL9','MFAP3L','MFSD1','MFSD2A','MGAT4C','MIB1','MICAL2','MICAL3','MICALL1','MICB','MIEN1','MIGA2','MISP','MKLN1','MKRN3','MLF2','MLKL','MLST8','MMACHC','MMP10','MMP15','MMP24','MMP25','MOAP1','MPHOSPH8','MPHOSPH9','MPI','MPIG6B','MPL','MPP1','MPP5','MPP7','MPZL1','MPZL2','MR1','MRGPRF','MRNIP','MRPL42','MRPL44','MRPL46','MRPS18B','MS4A1','MS4A12','MS4A14','MS4A15','MSN','MSRA','MTCP1','MTFR1L','MTHFR','MTM1','MTPN','MTSS1','MUC1','MUC20','MVD','MYH11','MYH9','MYL4','MYLK','MYO10','MYO1B','MYO1C','MYO1E','MYO1G','MYO3A','MYO5B','MYO9A','MYOF','N4BP2','NAA35','NAB1','NAIF1','NAMPT','NAP1L2','NAPG','NARFL','NCAM1','NCAM2','NCK1','NCKAP1L','NCKAP5','NCKIPSD','NCOA1','NCS1','NDC1','NECTIN2','NECTIN3','NECTIN4','NEDD1','NEDD9','NEO1','NEU1','NEXN','NF2','NFE2L2','NFKBID','NGEF']
MembraneProteins2=['NGFR','NHS','NHSL2','NID2','NINJ2','NKTR','NKX2-8','NLGN1','NLGN3','NLK','NLRX1','NMB','NMBR','NME1','NME2','NMT1','NMT2','NMUR2','NOS1','NOTCH2','NPFFR2','NPL','NPNT','NPR1','NPTN','NPTXR','NR2C1','NRAS','NRCAM','NRP2','NRSN1','NRXN1','NSD1','NSFL1C','NT5E','NTNG1','NTNG2','NTSR1','NUDCD3','NUDT16L1','NUDT9','NUMB','NUP35','NUS1','OAS3','OBSCN','OCA2','OCLN','OCM','OCM2','ODC1','ODR4','OGT','OLFM4','OLIG2','OLR1','OPHN1','OPRK1','OR10P1','OR1N2','OR2C3','OR6B2','OR6B3','OR6C6','OR8S1','OSBPL10','OSBPL6','OSBPL7','OSCAR','OSCP1','OSGEP','OSR2','OTOP2','OTULIN','OXGR1','P3H3','PACSIN2','PACSIN3','PAFAH1B2','PAG1','PAIP1','PAK1','PAK4','PAK6','PALLD','PALM','PALM2','PALM2-AKAP2','PALM3','PALMD','PANX1','PANX2','PAQR8','PARD3','PARD3B','PARD6A','PARD6G','PARP6','PATJ','PAWR','PCBD2','PCDH1','PCDH17','PCDH7','PCDHA1','PCDHA11','PCDHA12','PCDHA4','PCDHA5','PCDHB1','PCDHB11','PCDHB12','PCDHB16','PCDHB4','PCDHB5','PCDHGA1','PCDHGA10','PCDHGA11','PCDHGA12','PCDHGA2','PCDHGA3','PCDHGA4','PCDHGA5','PCDHGA6','PCDHGA7','PCDHGA8','PCDHGA9','PCDHGB1','PCDHGB2','PCDHGB3','PCDHGB4','PCDHGB5','PCDHGB6','PCDHGB7','PCDHGC3','PCDHGC4','PCDHGC5','PCLO','PCMTD1','PDAP1','PDCD7','PDE3A','PDE4A','PDE4D','PDE9A','PDGFC','PDGFRA','PDHX','PDLIM1','PDLIM5','PDPN','PDZD2','PDZD8','PEAR1','PEBP1','PFDN1','PGAP3','PGLYRP2','PGLYRP4','PGRMC2','PHACTR1','PHACTR4','PHF20L1','PHGDH','PHLDB2','PHLDB3','PHOSPHO1','PHPT1','PI3','PI4K2A','PI4KA','PIEZO2','PIGB','PIGN','PIGW','PIGX','PIK3AP1','PIK3CG','PIK3R6','PIP4K2A','PIP4K2C','PIP5K1A','PIRT','PITPNM3','PKD2L2','PKN1','PKN2','PKP1','PKP2','PKP3','PKP4','PLAA','PLAUR','PLCB1','PLCB2','PLCD3','PLCD4','PLEKHA4','PLEKHA6','PLEKHA7','PLEKHG3','PLEKHG4','PLEKHG6','PLEKHH2','PLEKHO2','PLIN4','PLPP1','PLPPR5','PLS3','PLSCR1','PLVAP','PLXNA3','PLXNA4','PNCK','PNISR','PODXL','POLE','POU2F3','PPEF1','PPFIBP1','PPIP5K1','PPL','PPM1A','PPM1F','PPP1CA','PPP1CB','PPP1R12B','PPP1R16A','PPP1R16B','PPP1R18','PPP1R27','PPP1R9A','PPP2R1B','PPP3R1','PPP3R2','PPP4C','PPP6R3','PPTC7','PRAME','PRC1','PRDX6','PRIMA1','PRKCA','PRKCE','PRKCH','PRKCZ','PRKD1','PROM2','PROSER2','PRR15','PRR32','PRR7','PRRC2A','PRRG1','PRRT2','PRRT3','PRRT4','PRTG','PRX','PSCA','PSD','PSD2','PSEN1','PSMC5','PSMC6','PSMD9','PSTPIP2','PTAFR','PTCHD4','PTK2B','PTK6','PTPN12','PTPN21','PTPN22','PTPN4','PTPRB','PTPRG','PTPRK','PTPRM','PTPRR','PTPRS','PTX3','PURG','PVALB','PVR','PXDC1','PXK','PYGL','PYGO2','PYM1','RAB13','RAB23','RAB25','RAB26','RAB27B','RAB3B','RAB3GAP2','RAB43','RAB8A','RABEPK','RAD51C','RAD52','RAI2','RALA','RALGAPA2','RAPGEF2','RAPH1','RAPSN','RASA4','RASA4B','RASAL1','RASAL2','RASAL3','RASD1','RASD2','RASGRP1','RASGRP2','RASGRP4','RASSF2','RASSF3','RASSF4','RBM46','RC3H1','RCCD1','RCSD1','RD3L','RDX','RECK','RELL1','REPS1','RET','RFLNB','RFPL1','RFPL2','RFPL3','RGP1','RGS10','RGS14','RGS19','RGS3','RGS7BP','RGS9BP','RHCE','RHD','RHEX','RHOA','RHOBTB2','RHOJ','RHOXF2','RHOXF2B','RIC8A','RIC8B','RIF1','RILPL1','RIMBP3','RIMBP3B','RIMBP3C','RIMS2','RIOK2','RIOK3','RIPK1','RND1','RNF114','RNF145','RNF146','RNF149','RNF165','RNF166','RNF39','ROBO1','ROBO3','ROBO4','ROM1','RP2','RPE','RPEL1','RPGRIP1L','RPIA','RPL36A','RPL36A-HNRNPH2','RPL36AL','RPSA','RPUSD1','RRAD','RRP12','RRP7A','RSBN1L','RSC1A1','RSPH3','RTL3','RTL4','RTN4R','RTN4RL1','RYR2','S100A13','S100A14','S100A16','S100A2','S100A3','S100A4','S100A6','S100A9','SAMD4A','SAMHD1','SAMSN1','SAPCD1','SASH3','SC5D','SCAMP1','SCAMP4','SCEL','SCHIP1','SCIN','SCN1A','SCN5A','SCN8A','SCN9A','SCNN1D','SCNN1G','SCRIB','SCUBE3','SDC2','SDC4','SDE2','SDHB','SEC16B','SEMA3C','SEMA3D','SEMA4B','SEMA4F','SEMA6C','SEMA6D','SEPT2','SEPT3','SERINC2','SERINC5','SERPINB3','SFSWAP','SGCE','SGK494','SH3BGR','SH3D21','SHANK1','SHANK3','SHARPIN','SHISA6','SHKBP1','SHROOM2','SHTN1','SIGLEC10','SIGLEC14','SIGLEC6','SIGLEC7','SIN3B','SIPA1','SIPA1L1','SIPA1L3','SKAP1','SLAMF6','SLC10A5','SLC12A2','SLC13A3','SLC13A5','SLC14A1','SLC16A1','SLC16A10','SLC16A2','SLC16A3','SLC16A7','SLC16A9','SLC17A5','SLC19A1','SLC19A3','SLC1A5','SLC1A6','SLC22A16','SLC23A3','SLC24A4','SLC26A9','SLC27A1','SLC28A1','SLC2A1','SLC2A11','SLC2A12','SLC2A14','SLC2A2','SLC2A3','SLC30A1','SLC31A2','SLC34A1','SLC34A2','SLC35F5','SLC35G2','SLC36A4','SLC38A5','SLC38A6','SLC38A7','SLC39A10','SLC39A14','SLC39A2','SLC39A6','SLC3A2','SLC40A1','SLC41A3','SLC43A1','SLC43A3','SLC44A2','SLC45A4','SLC46A1','SLC46A3','SLC4A1AP','SLC4A2','SLC4A7','SLC4A8','SLC5A12','SLC5A3','SLC5A6','SLC5A7','SLC6A6','SLC7A14','SLC7A2','SLC7A5','SLC7A6','SLC8A1','SLC9A1','SLC9A2','SLC9A3','SLC9A3R1','SLC9A3R2','SLC9A4','SLC9A5','SLC9B2','SLC9C2','SLCO1A2','SLCO1B3','SLCO4A1','SLCO4C1','SLCO5A1','SLIT1','SLIT3','SLITRK6','SLK','SLX4','SMAGP','SMAP1','SMOC1','SMPD2','SMPX','SNAP23','SNAP25','SNRK','SNTB2','SNTG2','SNX15','SNX32','SNX9','SOCS3','SOCS5','SOD1','SORBS1','SORCS1','SORT1','SOX11','SPAG16','SPANXN4','SPART','SPATA12','SPATC1L','SPERT','SPG11','SPHK1','SPINK13','SPINT1','SPINT2','SPN','SPPL2B','SPPL3','SPRED3','SPRYD3','SPTBN2','SRC','SRCIN1','SRD5A3','SRPK1','SRPRB','SRRM3','SSFA2','SSH1','SSH3','SSTR1','SSTR5','SSX2IP','ST8SIA5','STAB1','STAC','STAC2','STAMBP','STAMBPL1','STARD4','STAT2','STEAP4','STIL','STIP1','STK10','STK16','STK17A','STK17B','STOM','STOML2','STOML3','STX18','STX4','STXBP4','STYK1','SUCLG1','SUCLG2','SUGT1','SUMF2','SUPT6H','SUSD2','SVIL','SWAP70','SYCP2','SYK','SYMPK','SYNC','SYNGR3','SYNPO2L','SYPL2','SYT4','SYTL2','SYVN1','TACC2','TACR2','TACSTD2','TASP1','TAZ','TBC1D10A','TBC1D2','TBC1D24','TBC1D30','TBC1D9B','TBXA2R','TCAF2','TCAF2C','TCHP','TCIM','TDG','TDO2','TDP1','TEC','TEDC2','TEK','TES','TEX14','TEX9','TGFBR1','TGFBR2','TGM1','TGM2','THBS1','THBS2','THEGL','THY1','TIAM1','TICAM1','TIGD7','TIMD4','TJP1','TJP2','TJP3','TLN1','TLR4','TM2D2','TM4SF20','TM4SF4','TM4SF5','TMC5','TMED8','TMEM101','TMEM107','TMEM108','TMEM121B','TMEM139','TMEM141','TMEM164','TMEM176B','TMEM183A','TMEM186','TMEM2','TMEM218','TMEM222','TMEM229A','TMEM245','TMEM251','TMEM254','TMEM258','TMEM266','TMEM268','TMEM50A','TMEM63B','TMPRSS15','TMPRSS2','TMTC2','TNFRSF10D','TNFRSF11A','TNFRSF12A','TNFRSF21','TNFRSF25','TNFRSF8','TNFRSF9','TNFSF13B','TNK1','TNKS1BP1','TNNI2','TOGARAM2','TOLLIP','TOM1','TP53BP2','TPD52L1','TPRN','TRAF7','TRAIP','TRAPPC13','TRAT1','TRDN','TREML1','TRIB1','TRIM16','TRIM16L','TRIM38','TRIM4','TRIM44','TRIM54','TRIM71','TRIML2','TRIP6','TRMT1','TRMT10B','TRMT13','TRMT6','TRO','TRPM1','TRPM4','TRPM7','TRPV2','TRPV3','TSG101','TSGA13','TSHZ3','TSPAN15','TSPAN6','TSPO2','TSR2','TSSK4','TTC17','TTC23','TTC7B','TTLL12','TTLL5','TULP3','TWF2','TXNDC11','TXNIP','TYROBP','TYW3','UAP1','UBA3','UBA52','UBAC1','UBALD1','UBAP1','UBASH3B','UBE2A','UBE2B','UBE2C','UBE2D1','UBE2D2','UBE2D3','UBE2D4','UBE2K','UBE2QL1','UBE2S','UBE3C','UBQLN2','UBR2','UBTD1','UCP3','ULBP1','ULBP2','UNC5A','UNC79','UQCC1','USP14','USP15','USP2','USP20','USP21','USP4','USP53','UTP20','UTRN','VAMP5','VAMP8','VANGL1','VASP','VCAM1','VCPIP1','VIL1','VPS13B','VPS36','VPS50','VPS8','VSIG4','VTCN1','VWA5B1','VWA7','WAS','WASF2','WBP4','WDFY3','WDPCP','WDR1','WDR12','WDR13','WDR53','WDR6','WDR66','WIPF1','WWP1','XIAP','XIRP1','XIRP2','XPC','XPNPEP2','XPO6','XRN1','XYLT1','YES1','YIPF1','YIPF4','YOD1','YTHDC1','ZBED3','ZBTB33','ZBTB8OS','ZDHHC2','ZDHHC20','ZDHHC22','ZDHHC5','ZFP41','ZFP90','ZFYVE28','ZGPAT','ZMYND10','ZNF10','ZNF18','ZNF185','ZNF2','ZNF20','ZNF227','ZNF229','ZNF236','ZNF276','ZNF277','ZNF337','ZNF397','ZNF407','ZNF497','ZNF503','ZNF510','ZNF536','ZNF571','ZNF598','ZNF599','ZNF646','ZNF655','ZNF688','ZNF706','ZNF717','ZNF783','ZNF79','ZNF839','ZSCAN22','ZSCAN29','ZSWIM1','ZSWIM8','ZYX']
MembraneProteins=MembraneProteins1+MembraneProteins2

TFs1=['AC008770.3','AC023509.3','AC092835.1','AC138696.1','ADNP','ADNP2','AEBP1','AEBP2','AHCTF1','AHDC1','AHR','AHRR','AIRE','AKAP8','AKAP8L','AKNA','ALX1','ALX3','ALX4','ANHX','ANKZF1','AR','ARGFX','ARHGAP35','ARID2','ARID3A','ARID3B','ARID3C','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARX','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATMIN','ATOH1','ATOH7','ATOH8','BACH1','BACH2','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL11A','BCL11B','BCL6','BCL6B','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BNC1','BNC2','BORCS8-MEF2B','BPTF','BRF2','BSX','C11orf95','CAMTA1','CAMTA2','CARF','CASZ1','CBX2','CC2D1A','CCDC169-SOHLH2','CCDC17','CDC5L','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CGGBP1','CHAMP1','CHCHD3','CIC','CLOCK','CPEB1','CPXCR1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBL2','CREBZF','CREM','CRX','CSRNP1','CSRNP2','CSRNP3','CTCF','CTCFL','CUX1','CUX2','CXXC1','CXXC4','CXXC5','DACH1','DACH2','DBP','DBX1','DBX2','DDIT3','DEAF1','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMBX1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC2','DMTF1','DNMT1','DNTTIP1','DOT1L','DPF1','DPF3','DPRX','DR1','DRAP1','DRGX','DUX1','DUX3','DUX4','DUXA','DZIP1','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EBF1','EBF2','EBF3','EBF4','EEA1','EGR1','EGR2','EGR3','EGR4','EHF','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','EMX1','EMX2','EN1','EN2','EOMES','EPAS1','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','FAM170A','FAM200B','FBXL19','FERD3L','FEV','FEZF1','FEZF2','FIGLA','FIZ1','FLI1','FLYWCH1','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','GABPA','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD2A','GATAD2B','GBX1','GBX2','GCM1','GCM2','GFI1','GFI1B','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GPBP1','GPBP1L1','GRHL1','GRHL2','GRHL3','GSC','GSC2','GSX1','GSX2','GTF2B','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GZF1','HAND1','HAND2','HBP1','HDX','HELT','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIVEP1','HIVEP2','HIVEP3','HKR1','HLF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGN3','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HOMEZ','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','INSM1','INSM2','IRF1','IRF2','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','JAZF1','JDP2','JRK','JRKL','JUN','JUNB','JUND','KAT7','KCMF1','KCNIP3','KDM2A','KDM2B','KDM5B','KIN','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','L3MBTL1','L3MBTL3','L3MBTL4','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIN28A','LIN28B','LIN54','LMX1A','LMX1B','LTF','LYL1','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MAX','MAZ','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL2','MECOM','MECP2','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEOX1','MEOX2','MESP1','MESP2','MGA','MITF','MIXL1','MKX','MLX','MLXIP','MLXIPL','MNT','MNX1','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSX1','MSX2','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MXD1','MXD3','MXD4','MXI1','MYB','MYBL1','MYBL2','MYC','MYCL','MYCN','MYF5','MYF6','MYNN','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NME2','NOBOX','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NR0B1','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRF1','NRL','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OSR1','OSR2','OTP','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PATZ1','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PBX1','PBX2','PBX3','PBX4','PCGF2','PCGF6','PDX1','PEG3','PGR','PHF1','PHF19 ','PHF20','PHF21A','PHOX2A','PHOX2B','PIN1','PITX1','PITX2','PITX3','PKNOX1','PKNOX2','PLAG1','PLAGL1','PLAGL2','PLSCR1','POGK','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PRDM1','PRDM10','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM8','PRDM9','PREB','PRMT3','PROP1','PROX1','PROX2','PRR12','PRRX1','PRRX2','PTF1A','PURA','PURB','PURG','RAG1','RARA','RARB','RARG','RAX','RAX2','RBAK','RBCK1','RBPJ','RBPJL','RBSN','REL','RELA','RELB','REPIN1','REST','REXO4','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RHOXF1','RHOXF2','RHOXF2B','RLF','RORA','RORB','RORC','RREB1','RUNX1','RUNX2','RUNX3','RXRA','RXRB','RXRG','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SATB1','SATB2','SCMH1','SCML4','SCRT1','SCRT2','SCX','SEBOX','SETBP1','SETDB1','SETDB2','SGSM2','SHOX','SHOX2','SIM1','SIM2','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIL','SKOR1','SKOR2','SLC2A4RG','SMAD1','SMAD3','SMAD4','SMAD5','SMAD9','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SOHLH1','SOHLH2','SON','SOX1','SOX10','SOX11']
TFs2=['SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','ST18','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','T','TAL1','TAL2','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCF12','TCF15','TCF20','TCF21','TCF23','TCF24','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TET1','TET2','TET3','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGIF1','TGIF2','TGIF2LX','TGIF2LY','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRB','THYN1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TLX1','TLX2','TLX3','TMF1','TOPORS','TP53','TP63','TP73','TPRX1','TRAFD1','TRERF1','TRPS1','TSC22D1','TSHZ1','TSHZ2','TSHZ3','TTF1','TWIST1','TWIST2','UBP1','UNCX','USF1','USF2','USF3','VAX1','VAX2','VDR','VENTX','VEZF1','VSX1','VSX2','WIZ','WT1','XBP1','XPA','YBX1','YBX2','YBX3','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED9','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H8','ZEB1','ZEB2','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPM1','ZFPM2','ZFX','ZFY','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT4','ZNF10','ZNF100','ZNF101','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519','ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs=TFs1+TFs2

#TFs other, inclusive of the above list, not necessarily DNA binding proteins but affect transcription
TFs1Other=['AATF','ABL1','ABRA','AC008770.3','AC020915.1','AC023509.3','AC092835.1','AC105001.2','AC138696.1','ACOD1','ACTR3B','ACTR3C','ADAM8','ADAMTS17','ADAMTS19','ADAR','ADGRA1','ADGRG3','ADNP','ADNP2','AEBP1','AEBP2','AES','AFAP1 ','AFF1','AFF3','AFF4','AGER','AGT','AHCTF1','AHDC1','AHR','AHRR','AIM2','AIRE','AKAP8','AKAP8L','AKNA','AKT1','ALK','ALKBH2','ALX1','ALX3','ALX4','AMH','ANAPC2','ANHX','ANKRD30A','ANKZF1','ANXA3','ANXA4','AP5Z1','APBB3','APC2','APEX1','APOA4','APOBEC3A','APOBEC3B','APOBEC3G','APTX','AR','ARGFX','ARHGAP35','ARHGEF2','ARHGEF5','ARID1A','ARID1B','ARID2','ARID3A','ARID3B','ARID3C','ARID4A','ARID4B','ARID5A','ARID5B','ARNT','ARNT2','ARNTL','ARNTL2','ARRB1','ARRB2','ARX','ASCC1','ASCL1','ASCL2','ASCL3','ASCL4','ASCL5','ASH1L','ATF1','ATF2','ATF3','ATF4','ATF5','ATF6','ATF6B','ATF7','ATF7IP','ATM','ATMIN','ATOH1','ATOH7','ATOH8','ATR','ATRX','ATXN7','BACH1','BACH2','BAG1','BANF1','BANP','BARHL1','BARHL2','BARX1','BARX2','BATF','BATF2','BATF3','BAZ2A','BAZ2B','BBX','BCL10','BCL11A','BCL11B','BCL3','BCL6','BCL6B','BCLAF1','BCOR','BDP1','BEND4','BEX1','BHLHA15','BHLHA9','BHLHE22','BHLHE23','BHLHE40','BHLHE41','BHMG1','BIN1','BLM','BLZF1','BMI1','BMP2','BMP4','BMP7','BMPR1A','BNC1','BNC2','BOD1L1','BOLA1','BOLA2','BOLA2B','BOLA3','BORCS8-MEF2B','BPNT1','BPTF','BRCA1','BRD4','BRD7','BRD8','BRD9','BRF1','BRF2','BRMS1','BRPF1','BSX','BTAF1','BTBD8','BTG2','BTK','BTRC','BUD31','C11orf95','C14orf39','C17orf49','C1D','C20orf194','C3orf33','CACTIN','CAMK1D','CAMK2A','CAMTA1','CAMTA2','CAPN15','CAPN3','CARD11','CARD14','CARF','CARHSP1','CASP8AP2','CASZ1','CAT','CBFA2T2','CBFA2T3','CBFB','CBL','CBLL1','CBX2','CC2D1A','CC2D1B','CCDC124','CCDC169-SOHLH2','CCDC17','CCDC3','CCDC71','CCDC83','CCNT1','CCNT2','CD36','CD40','CD40LG','CDC5L','CDC6','CDK5RAP3','CDK7','CDK8','CDK9','CDKN1A','CDKN2A','CDX1','CDX2','CDX4','CEBPA','CEBPB','CEBPD','CEBPE','CEBPG','CEBPZ','CELF3','CENPA','CENPB','CENPBD1','CENPS','CENPT','CENPX','CERS2','CERS3','CERS4','CERS5','CERS6','CFLAR','CGGBP1','CHAMP1','CHCHD3','CHD1','CHD2','CHD3','CHD4','CHD6','CHD7','CHD9','CHP1','CHRAC1','CHUK','CHURC1','CIB1','CIC','CIITA','CIR1','CITED1','CITED2','CITED4','CIZ1','CLOCK','CLU','CMKLR1','CNBP','CNOT3','CNOT4','CNOT7','CNOT8','COMMD1','COMMD6','COMMD7','COPS2','COPS3','COPS4','CPEB1','CPSF4','CPSF4L','CPXCR1','CRAMP1','CREB1','CREB3','CREB3L1','CREB3L2','CREB3L3','CREB3L4','CREB5','CREBBP','CREBL2','CREBRF','CREBZF','CREG1','CREM','CRTC1','CRTC2','CRTC3','CRX','CSDC2','CSDE1','CSRNP1','CSRNP2','CSRNP3','CTBP1','CTBP2','CTCF','CTCFL','CTH','CTNNB1','CTNNBIP1','CUL1','CUL2','CUL3','CUL4A','CUL4B','CUL5','CUX1','CUX2','CXXC1','CXXC4','CXXC5','CYLD','CYP1B1','CYTL1','DAB2IP','DACH1','DACH2','DAP','DAXX','DBP','DBX1','DBX2','DCP1A','DDB1','DDB2','DDIT3','DDN','DDR2','DDRGK1','DDX3X','DDX5','DDX58','DEAF1','DEK','DEPDC1','DEPDC1B','DEPDC4','DEPDC5','DEPDC7','DEPTOR','DHX34','DHX36','DHX57','DISP3','DLX1','DLX2','DLX3','DLX4','DLX5','DLX6','DMAP1','DMBX1','DMC1','DMRT1','DMRT2','DMRT3','DMRTA1','DMRTA2','DMRTB1','DMRTC1','DMRTC2','DMTF1','DNA2','DNAJA3','DNAJC1','DNAJC2','DNAJC21','DNMT1','DNMT3A','DNMT3B','DNMT3L','DNTT','DNTTIP1','DOT1L','DPF1','DPF2','DPF3','DPRX','DR1','DRAP1','DRGX','DSP','DTX1','DUS3L','DUSP12','DUX1','DUX3','DUX4','DUXA','DVL1','DVL2','DVL3','DZIP1','DZIP1L','E2F1','E2F2','E2F3','E2F4','E2F5','E2F6','E2F7','E2F8','E4F1','EAF2','EBF1','EBF2','EBF3','EBF4','EDA','EDA2R','EDF1','EDN1','EEA1','EED','EGLN1','EGR1','EGR2','EGR3','EGR4','EHF','EID1','EID2','EIF2AK2','EIF2AK4','EIF3C','EIF3CL','EIF3K','ELF1','ELF2','ELF3','ELF4','ELF5','ELK1','ELK3','ELK4','ELMSAN1','EME1','EMX1','EMX2','EN1','EN2','ENO1','EOMES','EP300','EP400','EPAS1','EPHA5','EPM2AIP1','ERBIN','ERC1','ERCC3','ERCC4','ERF','ERG','ESR1','ESR2','ESRRA','ESRRB','ESRRG','ESX1','ETS1','ETS2','ETV1','ETV2','ETV3','ETV3L','ETV4','ETV5','ETV6','ETV7','EVX1','EVX2','EWSR1','EXO1','EXOC2','EXOG','EZH1','EZH2','FAAP24','FAM153C','FAM170A','FAM171B','FAM200A','FAM200B','FAN1','FANCA','FANCD2','FANK1','FARSA','FARSB','FBN1','FBXL19','FBXO41','FEN1','FER','FERD3L','FEV','FEZF1','FEZF2','FGD1','FHL2','FIGLA','FIZ1','FLI1','FLNA','FLYWCH1','FMNL2','FOS','FOSB','FOSL1','FOSL2','FOXA1','FOXA2','FOXA3','FOXB1','FOXB2','FOXC1','FOXC2','FOXD1','FOXD2','FOXD3','FOXD4','FOXD4L1','FOXD4L2','FOXD4L3','FOXD4L4','FOXD4L5','FOXD4L6','FOXE1','FOXE3','FOXF1','FOXF2','FOXG1','FOXH1','FOXI1','FOXI2','FOXI3','FOXJ1','FOXJ2','FOXJ3','FOXK1','FOXK2','FOXL1','FOXL2','FOXM1','FOXN1','FOXN2','FOXN3','FOXN4','FOXO1','FOXO3','FOXO4','FOXO6','FOXP1','FOXP2','FOXP3','FOXP4','FOXQ1','FOXR1','FOXR2','FOXS1','FUBP1','FUBP3','FUS','FZD1','FZD2','FZD4','FZD6','GABPA','GABPB1','GABPB2','GADD45A','GAS6','GAS7','GATA1','GATA2','GATA3','GATA4','GATA5','GATA6','GATAD1','GATAD2A','GATAD2B','GBX1','GBX2','GCFC2','GCM1','GCM2','GEN1','GFI1','GFI1B','GLA','GLI1','GLI2','GLI3','GLI4','GLIS1','GLIS2','GLIS3','GLMP','GLYR1','GMEB1','GMEB2','GOLGB1','GON4L','GPATCH8','GPBP1','GPBP1L1','GPER1','GPR155','GREM1','GRHL1','GRHL2','GRHL3','GRM6','GSC','GSC2','GSX1','GSX2','GTF2A1','GTF2A1L','GTF2A2','GTF2B','GTF2E2','GTF2F1','GTF2F2','GTF2H1','GTF2H2','GTF2H2C','GTF2H3','GTF2H4','GTF2I','GTF2IRD1','GTF2IRD2','GTF2IRD2B','GTF3A','GTF3C1','GTF3C2','GULP1','GZF1','H1F0','H1FOO','H1FX','HAND1','HAND2','HAVCR2','HBP1','HCFC1','HCK','HDAC1','HDAC10','HDAC2','HDAC3','HDAC4','HDAC5','HDAC6','HDAC7','HDAC8','HDAC9','HDX','HELT','HELZ','HELZ2','HES1','HES2','HES3','HES4','HES5','HES6','HES7','HESX1','HEY1','HEY2','HEYL','HHEX','HIC1','HIC2','HIF1A','HIF3A','HINFP','HIPK2','HIRA','HIST1H1A','HIST1H1B','HIST1H1C','HIST1H1D','HIST1H1E','HIST1H1T','HIVEP1','HIVEP2','HIVEP3','HKR1','HLA-DQB1','HLA-DQB2','HLA-DRB1','HLA-DRB3','HLA-DRB5','HLF','HLTF','HLX','HMBOX1','HMG20A','HMG20B','HMGA1','HMGA2','HMGB1','HMGB2','HMGB3','HMGB4','HMGN1','HMGN3','HMGXB3','HMGXB4','HMOX1','HMX1','HMX2','HMX3','HNF1A','HNF1B','HNF4A','HNF4G','HNRNPA1','HNRNPA3','HNRNPAB','HNRNPCL2','HNRNPD','HNRNPDL','HNRNPK','HNRNPL','HNRNPU','HOMEZ','HOOK2','HOPX','HOXA1','HOXA10','HOXA11','HOXA13','HOXA2','HOXA3','HOXA4','HOXA5','HOXA6','HOXA7','HOXA9','HOXB1','HOXB13','HOXB2','HOXB3','HOXB4','HOXB5','HOXB6','HOXB7','HOXB8','HOXB9','HOXC10','HOXC11','HOXC12','HOXC13','HOXC4','HOXC5','HOXC6','HOXC8','HOXC9','HOXD1','HOXD10','HOXD11','HOXD12','HOXD13','HOXD3','HOXD4','HOXD8','HOXD9','HP1BP3','HR','HSBP1','HSF1','HSF2','HSF4','HSF5','HSFX1','HSFX2','HSFY1','HSFY2','HSPA1A','HSPA1B','ICAM1','ID1','ID2','ID3','ID4','IFI16','IFNB1','IGHM','IKBKB','IKBKG','IKZF1','IKZF2','IKZF3','IKZF4','IKZF5','IL10','IL1B','IL1RAP','IL4','IL5','IL6','INF2','ING4','INS','INSM1','INSM2','IQGAP1','IRAK1','IRAK2','IRAK3','IRF1','IRF2','IRF2BP1','IRF3','IRF4','IRF5','IRF6','IRF7','IRF8','IRF9','IRX1','IRX2','IRX3','IRX4','IRX5','IRX6','ISL1','ISL2','ISX','ITCH','ITGB2','ITGB3BP','IZUMO2','JADE1','JAK2','JARID2','JAZF1','JDP2','JMY','JRK','JRKL','JUN','JUNB','JUND','JUP','KANSL2','KAT2A','KAT2B','KAT5','KAT6A','KAT6B','KAT7','KAT8','KCMF1','KCNIP3','KDM1A','KDM2A','KDM2B','KDM3A','KDM5A','KDM5B','KDM5C','KDM5D','KEAP1','KIAA1549','KIAA1683','KIAA1841','KIAA1958','KIF15','KIN','KIT','KLF1','KLF10','KLF11','KLF12','KLF13','KLF14','KLF15','KLF16','KLF17','KLF2','KLF3','KLF4','KLF5','KLF6','KLF7','KLF8','KLF9','KMT2A','KMT2B','KMT2C','KMT2D','KNTC1','KRAS','KRBOX1','KRT13','KRTAP5-1','KRTAP5-9','KRTAP9-9','L3MBTL1','L3MBTL3','L3MBTL4','LARP1','LARP1B','LARP4','LARP4B','LARP6','LARP7','LBX1','LBX2','LCOR','LCORL','LEF1','LEUTX','LGALS9','LGR4','LHX1','LHX2','LHX3','LHX4','LHX5','LHX6','LHX8','LHX9','LIG1','LIG3','LIN28A','LIN28B','LIN54','LMO2','LMO4','LMX1A','LMX1B','LPP','LRP5','LRP6','LRP8','LRRFIP1','LRRFIP2','LSR','LTF','LTN1','LYAR','LYL1','LZTFL1','LZTR1','LZTS1','MACC1','MACF1','MAD2L2','MAEL','MAF','MAFA','MAFB','MAFF','MAFG','MAFK','MALT1','MAML1','MAML3','MAP2K5','MAP3K10','MAP3K13','MAP3K7','MAPK1','MAPK10','MAPK11','MAPK14','MAPK3','MAPK8','MAPK9','MATR3','MAVS','MAX','MAZ','MB21D1','MBD1','MBD2','MBD3','MBD4','MBD6','MBNL1','MBNL2','MBNL3','MBTPS2','MDFI','MDM2','MDM4','MECOM','MECP2','MED1','MED12','MED13','MED13L','MED14','MED15','MED16','MED17','MED21','MED23','MED24','MED6','MEF2A','MEF2B','MEF2C','MEF2D','MEIS1','MEIS2','MEIS3','MEN1','MEOX1','MEOX2','MESP1','MESP2','MET','MGA','MGMT','MID2','MIER1','MIER2','MIER3','MINK1','MIS18BP1','MITF','MIXL1','MKL1','MKL2','MKRN1','MKRN2','MKRN3','MKX','MLLT1','MLLT10','MLLT11','MLLT3','MLLT6','MLX','MLXIP','MLXIPL','MN1','MNAT1','MNT','MNX1','MORC3','MPG','MRPL28','MRRF','MSANTD1','MSANTD3','MSANTD4','MSC','MSGN1','MSH2','MSH3','MSH6','MSL3','MSRB2','MST1R','MSX1','MSX2','MTA1','MTA2','MTA3','MTDH','MTERF1','MTERF2','MTERF3','MTERF4','MTF1','MTF2','MTPN','MUS81','MXD1','MXD3','MXD4','MXI1','MYB','MYBBP1A','MYBL1','MYBL2','MYC','MYCBP','MYCL','MYCN','MYD88','MYEF2','MYF5','MYF6','MYNN','MYOCD','MYOD1','MYOG','MYPOP','MYRF','MYRFL','MYSM1','MYT1','MYT1L','MZF1','NAB2','NABP2','NACC2','NAIF1','NANOG','NANOGNB','NANOGP8','NCOA1','NCOA2','NCOA3','NCOA4','NCOA5','NCOA6','NCOA7','NCOR1','NCOR2','NDC80','NDN','NDP','NEB','NEIL1','NEUROD1','NEUROD2','NEUROD4','NEUROD6','NEUROG1','NEUROG2','NEUROG3','NFAM1','NFAT5','NFATC1','NFATC2','NFATC3','NFATC4','NFE2','NFE2L1','NFE2L2','NFE2L3','NFE4','NFIA','NFIB','NFIC','NFIL3','NFIX','NFKB1','NFKB2','NFKBIA','NFKBIB','NFKBID','NFKBIL1','NFKBIZ','NFRKB','NFX1','NFXL1','NFYA','NFYB','NFYC','NHLH1','NHLH2','NKRF','NKX1-1','NKX1-2','NKX2-1','NKX2-2','NKX2-3','NKX2-4','NKX2-5','NKX2-6','NKX2-8','NKX3-1','NKX3-2','NKX6-1','NKX6-2','NKX6-3','NLRC3','NLRC4','NLRC5','NLRP12','NLRP2B','NLRP3','NME2','NOBOX','NOC3L','NOC4L','NOCT','NOD1','NOD2','NODAL','NONO','NOP2','NOTCH1','NOTCH2','NOTCH3','NOTO','NPAS1','NPAS2','NPAS3','NPAS4','NPM1','NR0B1','NR0B2','NR1D1','NR1D2','NR1H2','NR1H3','NR1H4','NR1I2','NR1I3','NR2C1','NR2C2','NR2E1','NR2E3','NR2F1','NR2F2','NR2F6','NR3C1','NR3C2','NR4A1','NR4A2','NR4A3','NR5A1','NR5A2','NR6A1','NRBF2','NRF1','NRG1','NRIP1','NRIP3','NRK','NRL','NSD1','NSD2','NTRK1','NUCKS1','NUFIP1','NUP98','NUPL2']
TFs2Other=['OGG1','OLIG1','OLIG2','OLIG3','ONECUT1','ONECUT2','ONECUT3','OPRD1','OSR1','OSR2','OTOP3','OTP','OTULIN','OTX1','OTX2','OVOL1','OVOL2','OVOL3','PA2G4','PABPN1','PARK7','PARP1','PARP10','PARP12','PATZ1','PAWR','PAX1','PAX2','PAX3','PAX4','PAX5','PAX6','PAX7','PAX8','PAX9','PAXBP1','PAXIP1','PBRM1','PBX1','PBX2','PBX3','PBX4','PCBD1','PCBP1','PCBP2','PCBP3','PCGF2','PCGF6','PCNA','PCSK6','PDCD7','PDS5B','PDX1','PEG3','PELI1','PER1','PER2','PER3','PEX14','PFDN1','PGBD1','PGR','PGS1','PHB','PHB2','PHF1','PHF19 ','PHF20','PHF21A','PHF5A','PHOX2A','PHOX2B','PHTF1','PHTF2','PIAS1','PIAS2','PIAS3','PIAS4','PIDD1','PIKFYVE','PIM1','PIN1','PINK1','PITX1','PITX2','PITX3','PKHD1','PKHD1L1','PKNOX1','PKNOX2','PLA2G10','PLA2G1B','PLAG1','PLAGL1','PLAGL2','PLEK','PLEK2','PLEKHA4','PLPP3','PLSCR1','PLXNA1','PLXNA2','PLXNA3','PLXNA4','PLXNB1','PLXNB2','PLXNB3','PLXNC1','PLXND1','PML','PMS1','PNKP','POGK','POGZ','POLA1','POLB','POLE3','POLE4','POLG','POLH','POLI','POLK','POLL','POLM','POLN','POLQ','POLR1B','POLR2A','POLR2B','POLR2E','POLR2J','POLR2K','POLR2L','POLR3A','POLRMT','POT1','POU1F1','POU2AF1','POU2F1','POU2F2','POU2F3','POU3F1','POU3F2','POU3F3','POU3F4','POU4F1','POU4F2','POU4F3','POU5F1','POU5F1B','POU5F2','POU6F1','POU6F2','PPARA','PPARD','PPARG','PPARGC1A','PPARGC1B','PPP1R10','PPP1R13L','PPP1R21','PPP2R3B','PPP2R5B','PPP3CA','PPRC1','PQBP1','PRAM1','PRAP1','PRB3','PRDM1','PRDM10','PRDM11','PRDM12','PRDM13','PRDM14','PRDM15','PRDM16','PRDM2','PRDM4','PRDM5','PRDM6','PRDM7','PRDM8','PRDM9','PRDX3','PREB','PREX1','PREX2','PRH2','PRIM2','PRIMPOL','PRKCB','PRKCH','PRKCI','PRKCQ','PRKCZ','PRKD1','PRKD2','PRKN','PRMT2','PRMT3','PRNP','PROP1','PROX1','PROX2','PRR12','PRR3','PRRX1','PRRX2','PSMA6','PSMC5','PSMD10','PSMD11','PSMD12','PSPC1','PTCH1','PTEN','PTF1A','PTGIS','PTH','PTTG1','PUM3','PURA','PURB','PURG','PYCARD','PYDC1','PYDC2','QRICH1','RAB11FIP4','RAB7B','RAD21','RAD51','RAG1','RAI1','RAPGEF3','RAPGEF4','RAPGEF5','RARA','RARB','RARG','RAX','RAX2','RB1','RBAK','RBBP7','RBCK1','RBL1','RBL2','RBM10','RBM20','RBM22','RBM26','RBM27','RBM5','RBM6','RBPJ','RBPJL','RBSN','RC3H1','RC3H2','RCAN1','RCOR1','RCOR2','RCOR3','RECQL','REL','RELA','RELB','RELL2','RELN','REPIN1','RERE','REST','REV1','REXO4','RFC1','RFX1','RFX2','RFX3','RFX4','RFX5','RFX6','RFX7','RFX8','RFXANK','RFXAP','RGCC','RGS11','RGS6','RGS7','RGS9','RHEBL1','RHOXF1','RHOXF2','RHOXF2B','RING1','RIOK2','RIPK1','RIPK2','RIPK3','RIPK4','RLF','RLIM','RNASE2','RNASEH1','RNF113A','RNF113B','RNF114','RNF125','RNF138','RNF14','RNF166','RNF2','RNF219','RNF25','RNF31','RNF4','RNF41','RORA','RORB','RORC','RPA2','RPA4','RPL36A','RPL7','RPL7A','RPS27A','RPS6KA4','RPS6KA5','RREB1','RRN3','RUNX1','RUNX1T1','RUNX2','RUNX3','RWDD3','RXRA','RXRB','RXRG','RYBP','S100A12','S100A8','S100A9','SAFB','SAFB2','SALL1','SALL2','SALL3','SALL4','SART1','SATB1','SATB2','SAV1','SCAND1','SCAND2P','SCAPER','SCMH1','SCML1','SCML2','SCML4','SCOC','SCRT1','SCRT2','SCX','SEBOX','SEMA4A','SERTAD1','SERTAD2','SETBP1','SETD6','SETDB1','SETDB2','SF3A2','SF3A3','SFPQ','SFRP4','SFRP5','SFTPB','SGK1','SGK3','SGSM2','SHH','SHOX','SHOX2','SHPRH','SIGIRR','SIK1','SIM1','SIM2','SIN3A','SIN3B','SIRT1','SIRT2','SIRT3','SIRT6','SIVA1','SIX1','SIX2','SIX3','SIX4','SIX5','SIX6','SKI','SKIDA1','SKIL','SKOR1','SKOR2','SLC22A4','SLC26A10','SLC26A3','SLC2A4RG','SLC30A9','SLC39A10','SLC4A10','SMAD1','SMAD2','SMAD3','SMAD4','SMAD5','SMAD6','SMAD7','SMAD9','SMARCA1','SMARCA2','SMARCA4','SMARCA5','SMARCAL1','SMARCB1','SMARCC1','SMARCC2','SMARCD1','SMARCD2','SMARCD3','SMARCE1','SMC3','SMO','SMUG1','SMYD1','SMYD3','SNAI1','SNAI2','SNAI3','SNAPC2','SNAPC4','SNAPC5','SNRPC','SNURF','SNW1','SOGA3','SOHLH1','SOHLH2','SON','SORBS2','SOX1','SOX10','SOX11','SOX12','SOX13','SOX14','SOX15','SOX17','SOX18','SOX2','SOX21','SOX3','SOX30','SOX4','SOX5','SOX6','SOX7','SOX8','SOX9','SP1','SP100','SP110','SP140','SP140L','SP2','SP3','SP4','SP5','SP6','SP7','SP8','SP9','SPDEF','SPEN','SPHK1','SPI1','SPIB','SPIC','SPZ1','SRCAP','SREBF1','SREBF2','SRF','SRY','SSB','SSBP2','SSBP3','SSBP4','SSH1','SSH2','SSH3','SSRP1','SSX1','ST18','STAG1','STAT1','STAT2','STAT3','STAT4','STAT5A','STAT5B','STAT6','STK16','STK3','STK36','STRN','STRN3','SUB1','SUFU','SUMO1','SUPT16H','SUPT4H1','SUPT5H','SUPT6H','SUV39H1','SUV39H2','SUZ12','SYK','T','TAB1','TAB2','TAB3','TADA2A','TADA2B','TADA3','TAF1','TAF10','TAF11','TAF12','TAF13','TAF1A','TAF1B','TAF1C','TAF1L','TAF2','TAF3','TAF4','TAF4B','TAF5','TAF5L','TAF6','TAF6L','TAF7','TAF7L','TAF8','TAF9','TAF9B','TAL1','TAL2','TARDBP','TAX1BP1','TBL1Y','TBP','TBPL1','TBPL2','TBR1','TBX1','TBX10','TBX15','TBX18','TBX19','TBX2','TBX20','TBX21','TBX22','TBX3','TBX4','TBX5','TBX6','TCEA2','TCEAL1','TCEAL7','TCEAL8','TCF12','TCF15','TCF19','TCF20','TCF21','TCF23','TCF24','TCF25','TCF3','TCF4','TCF7','TCF7L1','TCF7L2','TCFL5','TDG','TDP1','TDP2','TEAD1','TEAD2','TEAD3','TEAD4','TEF','TERB1','TERF1','TERF2','TERF2IP','TESMIN','TET1','TET2','TET3','TFAM','TFAP2A','TFAP2B','TFAP2C','TFAP2D','TFAP2E','TFAP4','TFCP2','TFCP2L1','TFDP1','TFDP2','TFDP3','TFE3','TFEB','TFEC','TGFB1','TGFB1I1','TGIF1','TGIF2','TGIF2LX','TGIF2LY','TGS1','THAP1','THAP10','THAP11','THAP12','THAP2','THAP3','THAP4','THAP5','THAP6','THAP7','THAP8','THAP9','THRA','THRAP3','THRB','THYN1','TIA1','TICAM1','TIGD1','TIGD2','TIGD3','TIGD4','TIGD5','TIGD6','TIGD7','TIPARP','TIRAP','TLE1','TLE2','TLE3','TLE4','TLE6','TLR2','TLR3','TLR4','TLR9','TLX1','TLX2','TLX3','TMEM235','TMF1','TNF','TNFAIP3','TNFRSF11A','TNFRSF4','TNFSF11','TNFSF18','TNFSF4','TOE1','TONSL','TOP1','TOP2A','TOP2B','TOPORS','TOX','TOX2','TOX3','TOX4','TP53','TP53BP1','TP63','TP73','TPRX1','TRADD','TRAF1','TRAF2','TRAF3','TRAF4','TRAF5','TRAF6','TRAFD1','TRAK2','TRAPPC9','TRERF1','TREX1','TRIB1','TRIB3','TRIM13','TRIM14','TRIM15','TRIM21','TRIM22','TRIM23','TRIM24','TRIM25','TRIM26','TRIM27','TRIM28','TRIM29','TRIM3','TRIM31','TRIM32','TRIM33','TRIM34','TRIM37','TRIM38','TRIM40','TRIM5','TRIM52','TRIM62','TRIM8','TRIP11','TRIT1','TRMT1','TRMT1L','TRPS1','TRRAP','TSC2','TSC22D1','TSC22D2','TSC22D3','TSC22D4','TSHZ1','TSHZ2','TSHZ3','TSN','TSSK4','TTF1','TUB','TULP4','TUT1','TWIST1','TWIST2','TXK','U2AF1','U2AF1L4','UBA52','UBB','UBC','UBE2K','UBE2N','UBE2V1','UBN1','UBP1','UBR4','UBTF','UBTFL1','UBTFL6','UFL1','UHRF1','UHRF2','UNCX','UNG','UNK','UNKL','USF1','USF2','USF3','USP39','USP7','UTF1','VAV1','VAX1','VAX2','VDR','VEGFA','VENTX','VEZF1','VGLL1','VGLL2','VGLL3','VHLL','VPS72','VSX1','VSX2','WDHD1','WFS1','WIZ','WNT1','WNT10B','WNT2','WNT3A','WNT5A','WNT8B','WRN','WT1','WWOX','WWP2','WWTR1','XBP1','XCL1','XPA','YBX1','YBX2','YBX3','YEATS2','YEATS4','YOD1','YY1','YY2','ZBED1','ZBED2','ZBED3','ZBED4','ZBED5','ZBED6','ZBED6CL','ZBED8','ZBED9','ZBP1','ZBTB1','ZBTB10','ZBTB11','ZBTB12','ZBTB14','ZBTB16','ZBTB17','ZBTB18','ZBTB2','ZBTB20','ZBTB21','ZBTB22','ZBTB24','ZBTB25','ZBTB26','ZBTB3','ZBTB32','ZBTB33','ZBTB34','ZBTB37','ZBTB38','ZBTB39','ZBTB4','ZBTB40','ZBTB41','ZBTB42','ZBTB43','ZBTB44','ZBTB45','ZBTB46','ZBTB47','ZBTB48','ZBTB49','ZBTB5','ZBTB6','ZBTB7A','ZBTB7B','ZBTB7C','ZBTB8A','ZBTB8B','ZBTB9','ZC3H10','ZC3H11A','ZC3H12A','ZC3H13','ZC3H14','ZC3H15','ZC3H18','ZC3H3','ZC3H4','ZC3H6','ZC3H7A','ZC3H7B','ZC3H8','ZC3HAV1','ZCCHC11','ZCCHC6','ZDHHC11','ZDHHC19','ZEB1','ZEB2','ZFAND5','ZFAT','ZFHX2','ZFHX3','ZFHX4','ZFP1','ZFP14','ZFP2','ZFP28','ZFP3','ZFP30','ZFP36','ZFP36L1','ZFP36L2','ZFP37','ZFP41','ZFP42','ZFP57','ZFP62','ZFP64','ZFP69','ZFP69B','ZFP82','ZFP90','ZFP91','ZFP92','ZFPL1','ZFPM1','ZFPM2','ZFR','ZFR2','ZFX','ZFY','ZFYVE26','ZGLP1','ZGPAT','ZHX1','ZHX2','ZHX3','ZIC1','ZIC2','ZIC3','ZIC4','ZIC5','ZIK1','ZIM2','ZIM3','ZKSCAN1','ZKSCAN2','ZKSCAN3','ZKSCAN4','ZKSCAN5','ZKSCAN7','ZKSCAN8','ZMAT1','ZMAT2','ZMAT3','ZMAT4','ZMAT5','ZMYM1','ZMYM2','ZMYM3','ZMYM4','ZMYM5','ZMYM6','ZMYND10','ZNF10','ZNF100','ZNF101','ZNF106','ZNF107','ZNF112','ZNF114','ZNF117','ZNF12','ZNF121','ZNF124','ZNF131','ZNF132','ZNF133','ZNF134','ZNF135','ZNF136','ZNF137P','ZNF138','ZNF14','ZNF140','ZNF141','ZNF142','ZNF143','ZNF146','ZNF148','ZNF154','ZNF155','ZNF157','ZNF16','ZNF160','ZNF165','ZNF169','ZNF17','ZNF174','ZNF175','ZNF177','ZNF18','ZNF180','ZNF181','ZNF182','ZNF184','ZNF185','ZNF189','ZNF19','ZNF195','ZNF197','ZNF2','ZNF20','ZNF200','ZNF202','ZNF205','ZNF207','ZNF208','ZNF211','ZNF212','ZNF213','ZNF214','ZNF215','ZNF217','ZNF219','ZNF22','ZNF221','ZNF222','ZNF223','ZNF224','ZNF225','ZNF226','ZNF227','ZNF229','ZNF23','ZNF230','ZNF232','ZNF233','ZNF234','ZNF235','ZNF236','ZNF239','ZNF24','ZNF248','ZNF25','ZNF250','ZNF251','ZNF253','ZNF254','ZNF256','ZNF257','ZNF26','ZNF260','ZNF263','ZNF264','ZNF266','ZNF267','ZNF268','ZNF273','ZNF274','ZNF275','ZNF276','ZNF277','ZNF28','ZNF280A','ZNF280B','ZNF280C','ZNF280D','ZNF281','ZNF282','ZNF283','ZNF284','ZNF285','ZNF286A','ZNF286B','ZNF287','ZNF292','ZNF296','ZNF3','ZNF30','ZNF300','ZNF302','ZNF304','ZNF311','ZNF316','ZNF317','ZNF318','ZNF319','ZNF32','ZNF320','ZNF322','ZNF324','ZNF324B','ZNF326','ZNF329','ZNF330','ZNF331','ZNF333','ZNF334','ZNF335','ZNF337','ZNF33A','ZNF33B','ZNF34','ZNF341','ZNF343','ZNF345','ZNF346','ZNF347','ZNF35','ZNF350','ZNF354A','ZNF354B','ZNF354C','ZNF355P','ZNF358','ZNF362','ZNF365','ZNF366','ZNF367','ZNF37A','ZNF382','ZNF383','ZNF384','ZNF385A','ZNF385B','ZNF385C','ZNF385D','ZNF391','ZNF394','ZNF395','ZNF396','ZNF397','ZNF398','ZNF404','ZNF407','ZNF408','ZNF41','ZNF410','ZNF414','ZNF415','ZNF416','ZNF417','ZNF418','ZNF419','ZNF420','ZNF423','ZNF425','ZNF426','ZNF428','ZNF429','ZNF43','ZNF430','ZNF431','ZNF432','ZNF433','ZNF436','ZNF438','ZNF439','ZNF44','ZNF440','ZNF441','ZNF442','ZNF443','ZNF444','ZNF445','ZNF446','ZNF449','ZNF45','ZNF451','ZNF454','ZNF460','ZNF461','ZNF462','ZNF467','ZNF468','ZNF469','ZNF470','ZNF471','ZNF473','ZNF474','ZNF479','ZNF48','ZNF480','ZNF483','ZNF484','ZNF485','ZNF486','ZNF487','ZNF488','ZNF490','ZNF491','ZNF492','ZNF493','ZNF496','ZNF497','ZNF500','ZNF501','ZNF502','ZNF503','ZNF506','ZNF507','ZNF510','ZNF511','ZNF512','ZNF512B','ZNF513','ZNF514','ZNF516','ZNF517','ZNF518A','ZNF518B','ZNF519']
TFs3Other=['ZNF521','ZNF524','ZNF525','ZNF526','ZNF527','ZNF528','ZNF529','ZNF530','ZNF532','ZNF534','ZNF536','ZNF540','ZNF541','ZNF542P','ZNF543','ZNF544','ZNF546','ZNF547','ZNF548','ZNF549','ZNF550','ZNF551','ZNF552','ZNF554','ZNF555','ZNF556','ZNF557','ZNF558','ZNF559','ZNF560','ZNF561','ZNF562','ZNF563','ZNF564','ZNF565','ZNF566','ZNF567','ZNF568','ZNF569','ZNF57','ZNF570','ZNF571','ZNF572','ZNF573','ZNF574','ZNF575','ZNF576','ZNF577','ZNF578','ZNF579','ZNF580','ZNF581','ZNF582','ZNF583','ZNF584','ZNF585A','ZNF585B','ZNF586','ZNF587','ZNF587B','ZNF589','ZNF592','ZNF593','ZNF594','ZNF595','ZNF596','ZNF597','ZNF598','ZNF599','ZNF600','ZNF605','ZNF606','ZNF607','ZNF608','ZNF609','ZNF610','ZNF611','ZNF613','ZNF614','ZNF615','ZNF616','ZNF618','ZNF619','ZNF620','ZNF621','ZNF622','ZNF623','ZNF624','ZNF625','ZNF626','ZNF627','ZNF628','ZNF629','ZNF630','ZNF638','ZNF639','ZNF641','ZNF644','ZNF645','ZNF646','ZNF648','ZNF649','ZNF652','ZNF653','ZNF654','ZNF655','ZNF658','ZNF66','ZNF660','ZNF662','ZNF664','ZNF665','ZNF667','ZNF668','ZNF669','ZNF670','ZNF671','ZNF672','ZNF674','ZNF675','ZNF676','ZNF677','ZNF678','ZNF679','ZNF680','ZNF681','ZNF682','ZNF683','ZNF684','ZNF687','ZNF688','ZNF689','ZNF69','ZNF691','ZNF692','ZNF695','ZNF696','ZNF697','ZNF699','ZNF7','ZNF70','ZNF700','ZNF701','ZNF703','ZNF704','ZNF705A','ZNF705B','ZNF705D','ZNF705E','ZNF705G','ZNF706','ZNF707','ZNF708','ZNF709','ZNF71','ZNF710','ZNF711','ZNF713','ZNF714','ZNF716','ZNF717','ZNF718','ZNF720','ZNF721','ZNF724','ZNF726','ZNF727','ZNF728','ZNF729','ZNF73','ZNF730','ZNF732','ZNF735','ZNF736','ZNF737','ZNF738','ZNF74','ZNF740','ZNF746','ZNF747','ZNF749','ZNF750','ZNF75A','ZNF75D','ZNF76','ZNF761','ZNF763','ZNF764','ZNF765','ZNF766','ZNF768','ZNF77','ZNF770','ZNF771','ZNF772','ZNF773','ZNF774','ZNF775','ZNF776','ZNF777','ZNF778','ZNF780A','ZNF780B','ZNF781','ZNF782','ZNF783','ZNF784','ZNF785','ZNF786','ZNF787','ZNF788','ZNF789','ZNF79','ZNF790','ZNF791','ZNF792','ZNF793','ZNF799','ZNF8','ZNF80','ZNF800','ZNF804A','ZNF804B','ZNF805','ZNF808','ZNF81','ZNF812P','ZNF813','ZNF814','ZNF816','ZNF821','ZNF823','ZNF827','ZNF829','ZNF83','ZNF830','ZNF831','ZNF835','ZNF836','ZNF837','ZNF839','ZNF84','ZNF841','ZNF843','ZNF844','ZNF845','ZNF846','ZNF85','ZNF850','ZNF852','ZNF853','ZNF860','ZNF862','ZNF865','ZNF878','ZNF879','ZNF880','ZNF883','ZNF888','ZNF891','ZNF90','ZNF91','ZNF92','ZNF93','ZNF98','ZNF99','ZNFX1','ZRANB2','ZRSR1','ZRSR2','ZSCAN1','ZSCAN10','ZSCAN12','ZSCAN16','ZSCAN18','ZSCAN2','ZSCAN20','ZSCAN21','ZSCAN22','ZSCAN23','ZSCAN25','ZSCAN26','ZSCAN29','ZSCAN30','ZSCAN31','ZSCAN32','ZSCAN4','ZSCAN5A','ZSCAN5B','ZSCAN5C','ZSCAN5DP','ZSCAN9','ZUFSP','ZXDA','ZXDB','ZXDC','ZZZ3']
TFs4Other=['ATF2','ATF6B','ATN1','BHLHA15','BHLHB2','BHLHB4 ','BHLHB5','BHLHB9','C13ORF8','C20ORF194','CDX2','CRAMP1L','ELP3','ERVK3-1','ETF1','FLJ12895','FLJ20321','FLJ25476','FLJ35784','FOXM1','FOXO2','FOXR1','FOXR2','GATA1','GRLF1','KDM4C','KDM4E','KIAA0863','KIAA0961','KLRG1','LBXCOR1','LEF1','LHX7','LOC126295','LOC51058','LOC91661','MGC4728','MYOD1','MYOG','MYRF','NEUROD4','NEUROG1','NFAT2','NFAT4','NFE2L1','NR1A2','NR1B1','NR1B2','NR1B3','NR1C1','NR1C2','NR1C3','NR1F3','NR1I1','NR2A1','NR2B3','NR3A1','NR3A2','NR3B3','OTEX','PEPP-2','PHF2','POU2F1','POU2F2','POU4F3','POU5F1','POU6F1','PRDM3','PRKRIP1','PRKRIR','SETD1A','SMAD8','SMYD2','SOX12','SOX14','SOX15','TBX14','TCF1','TCF17','TCF2','TCF9','TEAD1','TPRXL','UBTFL1','WHSC1','ZBTB14','ZBTB18','ZBTB19','ZBTB21','ZBTB27','ZBTB28','ZBTB35','ZBTB49','ZFP161','ZFP28','ZKSCAN10','ZKSCAN11','ZKSCAN12','ZKSCAN13','ZKSCAN14','ZKSCAN16','ZKSCAN19','ZKSCAN21','ZKSCAN24','ZKSCAN6','ZKSCAN8','ZNF10','ZNF112','ZNF187','ZNF193','ZNF204P','ZNF238','ZNF271','ZNF295','ZNF305','ZNF323','ZNF434','ZNF499','ZNF542','ZNF545','ZNF553','ZNF56','ZNF625','ZNF643','ZNF698','ZNF705F','ZNF751','ZNF752','ZNF753','ZNF785','ZNF806','ZNF816','ZNF833P','ZNF906','ZSCAN1','ZSCAN25','ZSCAN26','ZSCAN31','ZSCAN32','ZSCAN5D','ZSCAN9']
TFsOther=TFs1Other+TFs2Other+TFs3Other+TFs4Other
```

Example 8 (unknown):
```unknown
S genes: ['MCM5', 'PCNA', 'TYMS', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'DTL', 'PRIM1', 'UHRF1', 'HELLS', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'ATAD2', 'RAD51', 'RRM2', 'CDC45', 'CDC6', 'EXO1', 'TIPIN', 'DSCC1', 'BLM', 'CASP8AP2', 'USP1', 'CLSPN', 'POLA1', 'CHAF1B', 'BRIP1', 'E2F8'] 

G2 genes: ['HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'] 

Hemoglobin genes set 1: ['HBB', 'HBD', 'HBG1', 'HBG2', 'HBE1', 'HBZ', 'HBM', 'HBA2', 'HBA1', 'HBQ1'] 

Hemoglobin genes set 2: ['AHSP', 'GYPA', 'RHAG', 'GFI1B', 'KEL', 'EPB42', 'ALAS2', 'TSPO2', 'GYPB', 'GYPE', 'SPTA1', 'RHCE', 'KLF1', 'RHD', 'SLC4A1', 'SNX22', 'SQSTM1', 'SOD1', 'FTH1', 'MAP1LC3B', 'SLC25A37', 'TRIM58', 'HMBS'] 

Mitochondrial genes: ['MT-ND1', 'MT-ND2', 'MT-CO1', 'MT-CO2', 'MT-ATP8', 'MT-ATP6', 'MT-CO3', 'MT-ND3', 'MT-ND4L', 'MT-ND4', 'MT-ND5', 'MT-ND6', 'MT-CYB'] 

Ribo genes: ['RPLP0', 'RPLP1', 'RPLP2', 'RPL3', 'RPL3L', 'RPL4', 'RPL5', 'RPL6', 'RPL7', 'RPL7A', 'RPL7L1', 'RPL8', 'RPL9', 'RPL10', 'RPL10A', 'RPL10L', 'RPL11', 'RPL12', 'RPL13', 'RPL13A', 'RPL14', 'RPL15', 'RPL17', 'RPL18', 'RPL18A', 'RPL19', 'RPL21', 'RPL22', 'RPL22L1', 'RPL23', 'RPL23A', 'RPL24', 'RPL26', 'RPL26L1', 'RPL27', 'RPL27A', 'RPL28', 'RPL29', 'RPL30', 'RPL31', 'RPL32', 'RPL34', 'RPL35', 'RPL35A', 'RPL36', 'RPL36A', 'RPL36AL', 'RPL37', 'RPL37A', 'RPL38', 'RPL39', 'RPL39L', 'UBA52', 'RPL41', 'RPSA', 'RPS2', 'RPS3', 'RPS3A', 'RPS4X', 'RPS4Y1', 'RPS4Y2', 'RPS5', 'RPS6', 'RPS7', 'RPS8', 'RPS9', 'RPS10', 'RPS11', 'RPS12', 'RPS13', 'RPS14', 'RPS15', 'RPS15A', 'RPS16', 'RPS17', 'RPS18', 'RPS19', 'RPS20', 'RPS21', 'RPS23', 'RPS24', 'RPS25', 'RPS26', 'RPS27', 'RPS27A', 'RPS27L', 'RPS28', 'RPS29', 'FAU'] 

Tissue dissociation stress associated genes: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'SOCS3', 'CEBPD', 'CEBPB', 'ATF3', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'IER3', 'IER2', 'BTG1', 'BTG2', 'DUSP1']
```

Example 9 (python):
```python
#Expression: "YlGn" (e.g. DE plots)
#Divergent expression: "PRGn" (e.g. log2FC)
#Age: "afmhot_r"
#Others: "viridis" (e.g. UMAP expression)

#Define color palette
FineGrainPalette={
    'AtrialCardiomyocytesLeft':'#eac075',
    'AtrialCardiomyocytesRight':'#4c6b8a',
    'AtrialCardiomyocytesCycling':'#e94bc7',
    'VentricularCardiomyocytesLeftCompact':'#ab1c3c',
    'VentricularCardiomyocytesRightCompact':'#fdba45',
    'VentricularCardiomyocytesLeftTrabeculated':'#2b9200',
    'VentricularCardiomyocytesRightTrabeculated':'#0273a8',
    'VentricularCardiomyocytesCycling':'#e1acff',
    'SinoatrialNodePacemakerCells':'#854834',
    'AtrioventricularNodePacemakerCells':'#688500',
    'VentricularConductionSystemProximal':'#01ccc8',
    'VentricularConductionSystemDistal':'#b58fab',
    'GreatVesselAdventitialFibroblasts':'#ff7e97',
    'CoronaryVesselAdventitialFibroblasts':'#ff9b6e',
    'MyocardialInterstitialFibroblasts':'#8a6800',
    'SubEpicardialFibroblasts':'#206601',
    'Myofibroblasts':'#1bdebf',
    'LymphNodeFibroblasticReticularCells':'#005aa0',
    'ValveInterstitialCells':'#e478ff',
    'GreatVesselSmoothMuscleCells':'#ff665f',
    'CoronarySmoothMuscleCells':'#d2cb18',
    'DuctusArteriosusSmoothMuscleCells':'#83d7b3',
    'CoronaryPericytes':'#9088ff',
    'PericardialCellsIntermediate':'#c95e00',
    'PericardialCellsFibrous':'#01e077',
    'PericardialCellsParietal':'#ff88e4',
    'GreatVesselArterialEndothelialCells':'#d4004b',
    'GreatVesselVenousEndothelialCells':'#8f4300',
    'CoronaryArterialEndothelialCells':'#89da5a',
    'CoronaryVenousEndothelialCells':'#006f86',
    'CoronaryCapillaryEndothelialCells':'#aa7dff',
    'EndocardialCells':'#ff8241',
    'EndocardialCushionCells':'#46603a',
    'ValveEndothelialCells':'#414eb6',
    'LymphaticEndothelialCells':'#8b3f60',
    'MesothelialEpicardialCells':'#0295fe',
    'EpicardiumDerivedCells':'#ff92c4',
    'NeuronPrecursors':'#d30038',
    'ChromaffinCells':'#726800',
    'SympatheticNeurons':'#01894b',
    'ParaympatheticNeurons':'#545191',
    'SchwannCellPrecursors':'#b0d276',
    'SchwannCells':'#b30079',
    'MonocytesMPOpos':'#c50066',
    'Monocytes':'#fab4b6',
    'MonocyteDerivedCells':'#d14008',
    'MacrophagesCX3CR1pos':'#eabe97',
    'MacrophagesTIMD4pos':'#b2a200',
    'MacrophagesLYVE1pos':'#4a6005',
    'MacrophagesATF3pos':'#3db833',
    'DendriticCellsType1':'#007859',
    'DendriticCellsMature':'#01a9db',
    'PlasmacytoidDendriticCells':'#2c54ab',
    'MastCells':'#d0bef2',
    'Megakaryocytes':'#94298f',
    'TCellsCD4pos':'#ff387c',
    'TCellsCD8pos':'#9e3429',
    'TregsCD4pos':'#b37700',
    'ProBCells':'#8dab00',
    'BCells':'#a8d1a1',
    'BCellsMS4A1pos':'#00d2f0',
    'NaturalKillerCells':'#abb4ff',
    'InnateLymphoidCells':'#72497f',
}
sc.pl.umap(adata, color='fine_grain',palette=FineGrainPalette)

MidGrainPalette={
    'AtrialCardiomyocytes':'#af3a4d',
    'VentricularCardiomyocytes':'#b1756c',
    'CardiacConductionSystem':'#d45633',
    'Fibroblasts':'#9b6e4e',
    'MuralCells':'#ffb92f',
    'PericardialCells':'#b4f03b',
    'BloodVesselEndothelialCells':'#72cc57',
    'EndocardialCells':'#436e43',
    'LymphaticEndothelialCells':'#85cca0',
    'EpicardialCells':'#5eabb0',
    'Neurons':'#7bbdff',
    'Glia':'#403c90',
    'MyeloidCells':'#420066',
    'LymphoidCells':'#f553f6',
}
sc.pl.umap(adata, color='mid_grain',palette=MidGrainPalette)

CoarseGrainPalette={
    'Cardiomyocytes':'#bc5950',
    'Mesenchymal':'#af9c4c',
    'Endothelium':'#599e58',
    'Epicardium':'#5eabb0',
    'Neural':'#5e75b1',
    'Leukocytes':'#9a52a0',
}
sc.pl.umap(adata, color='coarse_grain',palette=CoarseGrainPalette)

RegionGrainPalette={
    'aorta':'#ffa2bc',
    'apex':'#fe0049',
    'atria':'#732d00',
    'atrial septum':'#ffd54c',
    'base':'#837100',
    'ductus arteriosus':'#bdff8b',
    'whole sample':'#1b6c00',
    'heart without node':'#02e6c6',
    'left ventricle':'#01c1f5',
    'node':'#00466d',
    'outflow tract':'#020011',
    'pericardium':'#7a75ff',
    'pulmonary arches and branches':'#30003e',
    'right ventricle':'#ff88e1',
    'right ventricle and papillaries':'#98004f',
}
sc.pl.umap(adata, color='region',palette=RegionGrainPalette)
```

Example 10 (python):
```python
set(adata.obs.fine_grain)
```

Example 11 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 12 (python):
```python
set(adata.obs.mid_grain)
```

Example 13 (unknown):
```unknown
{'AtrialCardiomyocytes',
 'BloodVesselEndothelialCells',
 'CardiacConductionSystem',
 'EndocardialCells',
 'EpicardialCells',
 'Fibroblasts',
 'Glia',
 'LymphaticEndothelialCells',
 'LymphoidCells',
 'MuralCells',
 'MyeloidCells',
 'Neurons',
 'PericardialCells',
 'VentricularCardiomyocytes'}
```

Example 14 (python):
```python
set(adata.obs.coarse_grain)
```

Example 15 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Leukocytes',
 'Mesenchymal',
 'Neural'}
```

Example 16 (python):
```python
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryVesselAdventitialFibroblasts','MyocardialInterstitialFibroblasts1','MyocardialInterstitialFibroblasts2','Myofibroblasts','GreatVesselAdventitialFibroblasts'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryArterialEndothelialCells','CoronaryCapillaryEndothelialCells','CoronaryVenousEndothelialCells','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells'])].copy()
#adata = adata[adata.obs['fine_grain'].isin(['CoronaryPericytes','CoronarySmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','GreatVesselSmoothMuscleCells'])].copy()
adata = adata[adata.obs['mid_grain'].isin(['PericardialCells'])].copy()
#adata=adata[adata.obs.mid_grain=='MuralCells',:].copy()
```

Example 17 (unknown):
```unknown
AnnData object with n_obs × n_vars = 16811 × 36601
    obs: 'latent_RT_efficiency', 'latent_cell_probability', 'latent_scale', 'sangerID', 'combinedID', 'donor', 'region', 'age', 'facility', 'cell_or_nuclei', 'modality', 'kit_10x', 'scrublet_score', 'doublet_pval', 'doublet_bh_pval', 'n_genes', 'n_counts', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo', 'pct_counts_ribo', 'HB_score', 'donor_by_library-prep', 'multiplexed', 'SOC | status', 'SOC | log_prob_singleton', 'SOC | log_prob_doublet', 'batch_key', '_scvi_batch', 'FACSgate', 'fine_grain', 'mid_grain', 'coarse_grain', 'sex', 'week', 'trimester', 'heart_or_greatvessels', 'cycling', 'S_score', 'G2M_score', 'phase', '_scvi_labels', 'stress_score', 'hb1_score'
    var: 'gene_name_scRNA-0', 'gene_id'
    uns: 'FACSgate_colors', '_scvi_manager_uuid', '_scvi_uuid', 'age_colors', 'cell_or_nuclei_colors', 'coarse_grain_colors', 'cycling_colors', 'donor_colors', 'fine_grain_colors', 'heart_or_greatvessels_colors', 'hvg', 'kit_10x_colors', 'mid_grain_colors', 'modality_colors', 'neighbors', 'phase_colors', 'region_colors', 'sex_colors', 'trimester_colors', 'umap', 'week_colors'
    obsm: 'X_scVI', 'X_umap', '_scvi_extra_categorical_covs', '_scvi_extra_continuous', '_scvi_extra_continuous_covs', 'latent_gene_encoding'
    obsp: 'connectivities', 'distances'
```

Example 18 (python):
```python
# preserve raw count
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5, batch_key='batch_key')
#sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

print(sum(adata.var.highly_variable))
sc.pl.highly_variable_genes(adata)

# freeze the state in `.raw`
adata.raw = adata

# subset hvgs
adata = adata[:, adata.var.highly_variable]

adata=adata.copy()

sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
#sc.pp.regress_out(adata, ['S_score','G2M_score'])

#batch correction
scvi.model.SCVI.setup_anndata(adata, 
                              layer="counts", 
                              batch_key="batch_key",
                              categorical_covariate_keys=['phase'],
                              continuous_covariate_keys=['total_counts','pct_counts_mt','pct_counts_ribo'])

vae = scvi.model.SCVI(adata, n_hidden = 128, n_latent = 50, n_layers = 3, dispersion = 'gene-batch')
vae.train(max_epochs=50)
    
# Convergence plot
x = np.linspace(1, (len(vae.history['elbo_train'])), (len(vae.history['elbo_train'])))
plt.plot(x, vae.history['elbo_train'], label="train")
plt.xlabel('epoch')
plt.ylabel('elbo_train')
plt.show()
plt.clf()

# add the latent space to adata
adata.obsm["X_scVI"] = vae.get_latent_representation()

sc.tl.score_genes(adata, stress_genes, score_name='stress_score')
sc.tl.score_genes(adata, hb_genes1, score_name='hb1_score')

sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata,min_dist=0.1)
#sc.tl.tsne(adata)
sc.pl.umap(adata, color=['log1p_total_counts','n_genes','n_genes_by_counts','total_counts','pct_counts_mt','pct_counts_ribo'],ncols=5)
sc.pl.umap(adata, color=['scrublet_score','stress_score', 'hb1_score','phase'], ncols=5,)

sc.pl.umap(adata, color=['donor','age','week','trimester','region','phase','cycling','cell_or_nuclei','modality','kit_10x','FACSgate','heart_or_greatvessels','coarse_grain','mid_grain','fine_grain'],wspace=0.8,ncols=5)
Genes=['TTN','TNNT2','MYOM1','LDB3','ALDH1A2','TNNT1','KRT19','UPK3B','BNC1','COL6A3','FBLN1','PCOLCE','LRRC17','PCDH18','EMCN','ECSCR','PECAM1','CDH5','ESAM', 'LAPTM5','PTPRC','LCP1','CD53','WAS','PHOX2B','NRXN1','STMN2','GRIK2','L1CAM']
sc.pl.umap(adata, color=Genes)
```

Example 19 (python):
```python
extracting highly variable genes
    finished (0:00:01)
--> added
    'highly_variable', boolean vector (adata.var)
    'means', float vector (adata.var)
    'dispersions', float vector (adata.var)
    'dispersions_norm', float vector (adata.var)
3620
```

Example 20 (python):
```python
calculating cell cycle phase
computing score 'S_score'
WARNING: genes are not in var_names and ignored: ['MCM5', 'FEN1', 'MCM2', 'MCM4', 'RRM1', 'UNG', 'GINS2', 'MCM6', 'CDCA7', 'PRIM1', 'UHRF1', 'RFC2', 'RPA2', 'NASP', 'RAD51AP1', 'GMNN', 'WDR76', 'SLBP', 'CCNE2', 'UBR7', 'POLD3', 'MSH2', 'RAD51', 'CDC45', 'CDC6', 'DSCC1', 'CASP8AP2', 'USP1', 'CLSPN', 'CHAF1B', 'E2F8']
    finished: added
    'S_score', score of gene set (adata.obs).
    418 total control genes are used. (0:00:00)
computing score 'G2M_score'
WARNING: genes are not in var_names and ignored: ['CKS1B', 'TMPO', 'ANP32E', 'TUBB4B', 'HJURP', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'PSRC1', 'LBR', 'CKAP5', 'CTCF', 'NEK2', 'CBX5', 'CENPA']
    finished: added
    'G2M_score', score of gene set (adata.obs).
    492 total control genes are used. (0:00:00)
-->     'phase', cell cycle phase (adata.obs)
```

Example 21 (unknown):
```unknown
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
```

Example 22 (unknown):
```unknown
Epoch 50/50: 100%|██████| 50/50 [02:04<00:00,  2.48s/it, loss=1.06e+03, v_num=1]
```

Example 23 (python):
```python
computing score 'stress_score'
WARNING: genes are not in var_names and ignored: ['FOS', 'FOSB', 'JUN', 'JUNB', 'JUND', 'ZFP36', 'CEBPB', 'EGR1', 'HSPA1A', 'HSPA1B', 'HSP90AA1', 'HSP90AB1', 'HSPA8', 'HSPB1', 'HSPE1', 'BTG1', 'DUSP1']
    finished: added
    'stress_score', score of gene set (adata.obs).
    197 total control genes are used. (0:00:00)
computing score 'hb1_score'
WARNING: genes are not in var_names and ignored: ['HBD', 'HBM', 'HBQ1']
    finished: added
    'hb1_score', score of gene set (adata.obs).
    298 total control genes are used. (0:00:00)
computing neighbors
    finished: added to `.uns['neighbors']`
    `.obsp['distances']`, distances for each pair of neighbors
    `.obsp['connectivities']`, weighted adjacency matrix (0:00:03)
computing UMAP
    finished: added
    'X_umap', UMAP coordinates (adata.obsm) (0:00:04)
```

Example 24 (unknown):
```unknown
... storing 'phase' as categorical
```

Example 25 (unknown):
```unknown
<Figure size 320x320 with 0 Axes>
```

Example 26 (python):
```python
adata.layers["counts"] = adata.X.copy()

# normalise and log-transform
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
```

Example 27 (unknown):
```unknown
normalizing counts per cell
    finished (0:00:01)
```

Example 28 (python):
```python
sc.tl.rank_genes_groups(adata, 'mid_grain', method='t-test', key_added = "t-test")
```

Example 29 (python):
```python
ranking genes
    finished: added to `.uns['t-test']`
    'names', sorted np.recarray to be indexed by group ids
    'scores', sorted np.recarray to be indexed by group ids
    'logfoldchanges', sorted np.recarray to be indexed by group ids
    'pvals', sorted np.recarray to be indexed by group ids
    'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:36)
```

Example 30 (python):
```python
set(adata.obs.coarse_grain)
```

Example 31 (unknown):
```unknown
{'Cardiomyocytes',
 'Endothelium',
 'Epicardium',
 'Leukocytes',
 'Mesenchymal',
 'Neural'}
```

Example 32 (python):
```python
set(adata.obs.fine_grain)
```

Example 33 (unknown):
```unknown
{'AtrialCardiomyocytesCycling',
 'AtrialCardiomyocytesLeft',
 'AtrialCardiomyocytesRight',
 'AtrioventricularNodePacemakerCells',
 'BCells',
 'BCellsMS4A1pos',
 'ChromaffinCells',
 'CoronaryArterialEndothelialCells',
 'CoronaryCapillaryEndothelialCells',
 'CoronaryPericytes',
 'CoronarySmoothMuscleCells',
 'CoronaryVenousEndothelialCells',
 'CoronaryVesselAdventitialFibroblasts',
 'DendriticCellsMature',
 'DendriticCellsType1',
 'DuctusArteriosusSmoothMuscleCells',
 'EndocardialCells',
 'EndocardialCushionCells',
 'EpicardiumDerivedCells',
 'GreatVesselAdventitialFibroblasts',
 'GreatVesselArterialEndothelialCells',
 'GreatVesselSmoothMuscleCells',
 'GreatVesselVenousEndothelialCells',
 'InnateLymphoidCells',
 'LymphNodeFibroblasticReticularCells',
 'LymphaticEndothelialCells',
 'MacrophagesATF3pos',
 'MacrophagesCX3CR1pos',
 'MacrophagesLYVE1pos',
 'MacrophagesTIMD4pos',
 'MastCells',
 'Megakaryocytes',
 'MesothelialEpicardialCells',
 'MonocyteDerivedCells',
 'Monocytes',
 'MonocytesMPOpos',
 'MyocardialInterstitialFibroblasts',
 'Myofibroblasts',
 'NaturalKillerCells',
 'NeuronPrecursors',
 'ParaympatheticNeurons',
 'PericardialCellsFibrous',
 'PericardialCellsIntermediate',
 'PericardialCellsParietal',
 'PlasmacytoidDendriticCells',
 'ProBCells',
 'SchwannCellPrecursors',
 'SchwannCells',
 'SinoatrialNodePacemakerCells',
 'SubEpicardialFibroblasts',
 'SympatheticNeurons',
 'TCellsCD4pos',
 'TCellsCD8pos',
 'TregsCD4pos',
 'ValveEndothelialCells',
 'ValveInterstitialCells',
 'VentricularCardiomyocytesCycling',
 'VentricularCardiomyocytesLeftCompact',
 'VentricularCardiomyocytesLeftTrabeculated',
 'VentricularCardiomyocytesRightCompact',
 'VentricularCardiomyocytesRightTrabeculated',
 'VentricularConductionSystemDistal',
 'VentricularConductionSystemProximal'}
```

Example 34 (python):
```python
ClusterOfInterest='BloodVesselEndothelialCells'
FineGrainCategoriesOrder=['AtrialCardiomyocytesLeft','AtrialCardiomyocytesRight','AtrialCardiomyocytesCycling','VentricularCardiomyocytesLeftCompact','VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesCycling','SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells','VentricularConductionSystemProximal','VentricularConductionSystemDistal','GreatVesselAdventitialFibroblasts','CoronaryVesselAdventitialFibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts','Myofibroblasts','LymphNodeFibroblasticReticularCells','ValveInterstitialCells','GreatVesselSmoothMuscleCells','CoronarySmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','CoronaryPericytes','PericardialCellsIntermediate','PericardialCellsFibrous','PericardialCellsParietal','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','CoronaryArterialEndothelialCells','CoronaryVenousEndothelialCells','CoronaryCapillaryEndothelialCells','EndocardialCells','EndocardialCushionCells','ValveEndothelialCells','LymphaticEndothelialCells','MesothelialEpicardialCells','EpicardiumDerivedCells','NeuronPrecursors','ChromaffinCells','SympatheticNeurons','ParaympatheticNeurons','SchwannCellPrecursors','SchwannCells','MonocytesMPOpos','Monocytes','MonocyteDerivedCells','MacrophagesCX3CR1pos','MacrophagesTIMD4pos','MacrophagesLYVE1pos','MacrophagesATF3pos','DendriticCellsType1','DendriticCellsMature','PlasmacytoidDendriticCells','MastCells','Megakaryocytes','TCellsCD4pos','TCellsCD8pos','TregsCD4pos','ProBCells','BCells','BCellsMS4A1pos','NaturalKillerCells','InnateLymphoidCells']
DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn')
```

Example 35 (python):
```python
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_248106/4017030311.py in <module>
      1 ClusterOfInterest='BloodVesselEndothelialCells'
      2 FineGrainCategoriesOrder=['AtrialCardiomyocytesLeft','AtrialCardiomyocytesRight','AtrialCardiomyocytesCycling','VentricularCardiomyocytesLeftCompact','VentricularCardiomyocytesRightCompact','VentricularCardiomyocytesLeftTrabeculated','VentricularCardiomyocytesRightTrabeculated','VentricularCardiomyocytesCycling','SinoatrialNodePacemakerCells','AtrioventricularNodePacemakerCells','VentricularConductionSystemProximal','VentricularConductionSystemDistal','GreatVesselAdventitialFibroblasts','CoronaryVesselAdventitialFibroblasts','SubEpicardialFibroblasts','MyocardialInterstitialFibroblasts','Myofibroblasts','LymphNodeFibroblasticReticularCells','ValveInterstitialCells','GreatVesselSmoothMuscleCells','CoronarySmoothMuscleCells','DuctusArteriosusSmoothMuscleCells','CoronaryPericytes','PericardialCellsIntermediate','PericardialCellsFibrous','PericardialCellsParietal','GreatVesselArterialEndothelialCells','GreatVesselVenousEndothelialCells','CoronaryArterialEndothelialCells','CoronaryVenousEndothelialCells','CoronaryCapillaryEndothelialCells','EndocardialCells','EndocardialCushionCells','ValveEndothelialCells','LymphaticEndothelialCells','MesothelialEpicardialCells','EpicardiumDerivedCells','NeuronPrecursors','ChromaffinCells','SympatheticNeurons','ParaympatheticNeurons','SchwannCellPrecursors','SchwannCells','MonocytesMPOpos','Monocytes','MonocyteDerivedCells','MacrophagesCX3CR1pos','MacrophagesTIMD4pos','MacrophagesLYVE1pos','MacrophagesATF3pos','DendriticCellsType1','DendriticCellsMature','PlasmacytoidDendriticCells','MastCells','Megakaryocytes','TCellsCD4pos','TCellsCD8pos','TregsCD4pos','ProBCells','BCells','BCellsMS4A1pos','NaturalKillerCells','InnateLymphoidCells']
----> 3 DEGenesForCluster = [x[ClusterOfInterest] for x in adata.uns['t-test']['names'][:50]]
      4 sc.pl.dotplot(adata, DEGenesForCluster ,groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn')

~/miniconda3/envs/scanpynew/lib/python3.8/site-packages/anndata/compat/_overloaded_dict.py in __getitem__(self, key)
     98             return self.overloaded[key].get()
     99         else:
--> 100             return self.data[key]
    101 
    102     def __setitem__(self, key, value):

KeyError: 't-test'
```

Example 36 (python):
```python
sc.pl.dotplot(adata, ['TNNT2','ACTN2','LDB3','COL6A3','PCOLCE','LRRC17','EGFL7','PECAM1','CALCRL','ALDH1A2','BNC1','UPK3B','PHOX2B','NRXN1','SORCS1','PTPRC','RUNX1','DOCK2'] ,var_group_positions=[(0,2),(3,5),(6,8),(9,11),(12,14),(15,17)], var_group_labels=['Cardiomyocytes','Mesenchymal','Endothelium','Epicardium','Neural','Leukocytes'], var_group_rotation=45,groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn')
```

Example 37 (python):
```python
sc.pl.dotplot(adata, ['BNC1','WT1','TCF21'],groupby='fine_grain',categories_order=FineGrainCategoriesOrder,standard_scale='var',cmap='YlGn')
```

Example 38 (python):
```python
ax = sc.pl.correlation_matrix(adata, 'fine_grain', figsize=(25,20),cmap='PRGn')
```

Example 39 (python):
```python
#Infer the sex of donors; run for multiome and scRNA separately

chrY_genes=['SRY', 'RPS4Y1', 'ZFY', 'ZFY-AS1', 'LINC00278', 'PCDH11Y', 'TTTY2B', 'TBL1Y', 'PRKY', 'USP9Y', 'DDX3Y', 'UTY', 'TMSB4Y', 'NLGN4Y', 'TTTY14', 'KDM5D', 'TTTY10', 'EIF1AY', 'PRORY', 'LINC00266-4P']

# scRNA 
bdata=sc.read('./Objects/Feb28ObjectRaw.h5ad')
adata=bdata[bdata.obs.modality=='scRNA',:].copy()

adata.obs['percent_chrY'] = np.sum(adata[:, chrY_genes].X, axis=1).A1 / np.sum(adata.X, axis=1).A1 * 100
adata.obs["XIST-counts"] = adata.X[:,adata.var_names.str.match('XIST')].toarray()#sns.jointplot('total_counts', 'pct_counts_mt', data=adata.obs, kind="scatter")
sc.pl.scatter(adata, x='XIST-counts', y='percent_chrY', color="donor")
sc.pl.violin(adata, ["XIST-counts", "percent_chrY"], jitter=0., groupby = 'donor', rotation= 90,figsize=(25,20))

#Multiome
adata=bdata[bdata.obs.modality=='scMultiome',:].copy()

adata.obs['percent_chrY'] = np.sum(adata[:, chrY_genes].X, axis=1).A1 / np.sum(adata.X, axis=1).A1 * 100
adata.obs["XIST-counts"] = adata.X[:,adata.var_names.str.match('XIST')].toarray()#sns.jointplot('total_counts', 'pct_counts_mt', data=adata.obs, kind="scatter")
sc.pl.scatter(adata, x='XIST-counts', y='percent_chrY', color="donor")
sc.pl.violin(adata, ["XIST-counts", "percent_chrY"], jitter=0., groupby = 'donor', rotation= 90,figsize=(25,20))
```

Example 40 (unknown):
```unknown
bdata.obs.modality
```

Example 41 (unknown):
```unknown
barcode
BHF_F_Hea10402917_TGGCTGGGTTGTGGAG-1                             scRNA
BHF_F_Hea10402917_ATGTGTGTCGAACGGA-1                             scRNA
BHF_F_Hea10402917_CAGGTGCAGGCTATCT-1                             scRNA
BHF_F_Hea10402917_TACAGTGTCCAGTATG-1                             scRNA
BHF_F_Hea10402917_ACCAGTATCCACTCCA-1                             scRNA
                                                               ...    
HCAHeartST13386010_HCAHeartST13303420_ATGGCTTAGTGAGGTA-1    scMultiome
HCAHeartST13386010_HCAHeartST13303420_GAACCAGCAGCATGAG-1    scMultiome
HCAHeartST13386010_HCAHeartST13303420_GCGCAATGTAAACAAG-1    scMultiome
HCAHeartST13386010_HCAHeartST13303420_CGTAATGGTATTGAGT-1    scMultiome
HCAHeartST13386010_HCAHeartST13303420_GCTGTAAGTCAATACG-1    scMultiome
Name: modality, Length: 297473, dtype: category
Categories (2, object): ['scMultiome', 'scRNA']
```

Example 42 (python):
```python
gene = 'GJA1'
key_1 = 'week'
key_2 = 'fine_grain'

# subset anndata of a gene of interest
ad = adata[:,list(adata.var_names).index(gene)]
# add gene expression to .obs
ad.obs[gene] = ad.to_df()
# groupby two keys
# this is mean expression
df = ad.obs[[key_1,key_2,gene]]
df = df.groupby([key_1,key_2]).mean().unstack(level=0)
df.columns = df.columns.get_level_values(1)
# plot
plt.rcParams['figure.figsize'] = 4.5,18  # width, height
sns.heatmap(df,cmap='viridis')
plt.title(gene)
```

Example 43 (unknown):
```unknown
Trying to set attribute `.obs` of view, copying.
```

Example 44 (unknown):
```unknown
Text(0.5, 1.0, 'GJA1')
```

Example 45 (python):
```python
gene = 'NPPA'
key_1 = 'week'
key_2 = 'fine_grain'

# subset anndata of a gene of interest
ad = adata[:,list(adata.var_names).index(gene)]
# add gene expression to .obs
ad.obs[gene] = ad.to_df()
# groupby two keys
# this is mean expression
df = ad.obs[[key_1,key_2,gene]]
df = df.groupby([key_1,key_2]).mean().unstack(level=0)
df.columns = df.columns.get_level_values(1)
# plot
plt.rcParams['figure.figsize'] = 4.5,18  # width, height
sns.heatmap(df,cmap='viridis')
plt.title(gene)
```

Example 46 (unknown):
```unknown
Trying to set attribute `.obs` of view, copying.
```

Example 47 (unknown):
```unknown
Text(0.5, 1.0, 'NPPA')
```

---
