# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import pandas as pd
import numpy as np
import sys
import os
import time
import random
import copy
import math
import scanpy as sc
# %matplotlib inline
from matplotlib import pyplot as plt
import matplotlib as mpl
import seaborn as sns
import autoreload
import scipy
params = {
    'font.size': 12,
    'axes.titlesize': 12,
    'axes.labelsize': 12,
    'legend.fontsize': 12,
    'xtick.labelsize': 8,
    'ytick.labelsize': 10,
    'font.family': "Helvetica",
    'pdf.fonttype': 42,
    'ps.fonttype': 42,
    'figure.dpi': 100
   }

mpl.rcParams.update(params)

sns.set_style("ticks")
sns.set_context(context='paper')
savefig_args = {"dpi": 300, "bbox_inches": "tight", "pad_inches": 0, "transparent": False}
mpl.rc('savefig', dpi=300)
output_dir='figures/10.12.20/'
output_suffix = ""
output_formats = [".png", ".pdf"]

def save_figure(fig, name, output_dir=output_dir, output_suffix=output_suffix, output_formats=output_formats, savefig_args=savefig_args):
    for output_format in output_formats:
        fig.savefig(output_dir + "/" + name + output_suffix + output_format, **savefig_args)
    return None

pd.set_option('display.max_rows', 50)
pd.set_option('display.max_columns', 20) 
pd.set_option('display.width', 100)
# %load_ext autoreload
# %autoreload 2
cfgFile = '../switchy/Prototyping.ini'

sc.set_figure_params(color_map='viridis')

# + [markdown] jupyter={"outputs_hidden": true}
# IL_genes = list(adata.var.index[adata.var.index.str.contains("IL")])
#
# sc.pl.umap(adata, color = IL_genes)
# -

# ## Analysis

filename = 'Current.h5ad'
adata = sc.read_h5ad(filename)

fig, ax = plt.subplots(1,1)
plt.hist(adata.obs.n_counts, histtype='step', color = 'k')
plt.hist(adata.obs.n_counts, histtype='stepfilled', color = 'k', alpha = 0.2)
plt.title('Uniquely Mapped Reads')

adata.obs

g = sns.violinplot(data = adata.obs, x ='n_counts', y = 'Treatment', hue = 'Experimental_Label')

g.figure.savefig('figures/N_counts', transparent=True)

g = sns.violinplot(data = adata.obs, x ='n_genes', y = 'Treatment', hue = 'Experimental_Label')

adata.obs.columns

g.figure.savefig('figures/N_genes', transparent=True)

variable = 'phase'
sc.pl.umap(adata, color = variable, title = 'Cell Cycle Phase', frameon = False, size = 200, alpha=0.6, save = variable)

StarcoderdataJupyterScriptsDedupFiltered