In [15]:
import os
import json

import tqdm
import glob
from imp import reload

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
from sklearn.preprocessing import normalize
from scipy.optimize import minimize

import deltascope as ds

In [23]:
%matplotlib inline

In [3]:
# --------------------------------
# -------- User input ------------
# --------------------------------

# Specify path to exported landmark data
lmpath = glob.glob('*landmarks.csv')
binpath = glob.glob('*landmarks_bins.json')
print(lmpath,binpath)

# Pick the correct path from the list
lmpath = lmpath[0]
binpath = binpath[0]


Out[3]:
('01-27-01-54_landmarks.csv', '01-27-01-54_landmarks_bins.json')

In [5]:
# Load landmarks from csv
oldlm = pd.read_csv(lmpath)

In [9]:
# Load landmark bins 
with open(binpath,'r') as f:
    bins = json.load(f)
acbins = bins['acbins']
tbins = bins['tbins']

In [16]:
colors = ['#41ab5d','#ef3b2c','#00441b','#67000d']
tarr = np.round(tbins,2)
xarr = np.round(acbins,2)
tpairs = [[tarr[0],tarr[4]],[tarr[1],tarr[5]],[tarr[2],tarr[6]],[tarr[3],tarr[7]]]

Restructure Data

We will sort landmark data according to stype and organize it in a two tiered dictionary according to sample type (s) and channel (c).


In [12]:
Dlm = {}
for stype in tqdm.tqdm(oldlm.stype.unique()):
    # These two lines may need to be modified based on stype structure
    s = stype.split('-')[0]
    c = stype.split('-')[-1]
    
    # Add sample type dictionary if not already present
    if s not in Dlm.keys():
        Dlm[s] = {}
    
    # Save sample specific landmark data to dictionary
    Dlm[s][c] = oldlm[oldlm.stype==stype]


100%|██████████| 4/4 [00:00<00:00, 362.96it/s]

Graphs


In [32]:
gs = ds.graphSet(tpairs,xarr,tarr)
dtype = 'r'

gs.add_data(
    ds.graphData(Dlm['you']['ZRF'],colors[3]),
    'you','zrf',dtype)
gs.add_data(
    ds.graphData(Dlm['wt']['ZRF'],colors[1]),
    'wt','zrf',dtype)
gs.add_data(
    ds.graphData(Dlm['you']['AT'],colors[2]),
    'you','at',dtype)
gs.add_data(
    ds.graphData(Dlm['wt']['AT'],colors[0]),
    'wt','at',dtype)

gs.make_figure(0.3,'you',figsize=(10,20),P=True,pthresh=0.01)


1.0683760683760684e-05
1.0683760683760684e-05