Example #1
0
# imports the pcreode package
import pcreode
# matplotlib is a commonly used package for plotting
import matplotlib.pyplot as plt
# pandas is a package used for making the handling of large data sets easier
import pandas as pd
# numpy is very common package for handling arrays and matrices
import numpy as np

import pdb

file_nm = "./Myeloid_with_IDs.csv"

data_raw = pd.read_csv(file_nm)
data_raw.head()
data_pca = pcreode.PCA(data_raw)
data_pca.get_pca()

pca_test_data = data_pca.pca_set_components(5)
pca_reduced_data = data_pca.pca_set_components(3)

dens = pcreode.Density(pca_reduced_data)
density_1 = dens.get_density(radius=1.0)
noise = 8.0
target = 50.0
file_path = './myeloid_w_ids/'

#pdb.set_trace()
out_graph, out_ids = pcreode.pCreode(data=pca_reduced_data,
                                     density=density_1,
                                     noise=noise,
Example #2
0
import time
checkpoints = {}

#   ____________________________________________________________________________
#   Load data                                                               ####
expression = pd.read_csv("/ti/input/expression.csv", index_col=[0])
params = json.load(open("/ti/input/params.json", "r"))

checkpoints["method_afterpreproc"] = time.time()

#   ____________________________________________________________________________
#   Infer trajectory                                                        ####
# pCreode using https://github.com/KenLauLab/pCreode/blob/master/notebooks/pCreode_tutorial.ipynb

# preprocess using pca
data_pca = pcreode.PCA(expression)
data_pca.get_pca()

pca_reduced_data = data_pca.pca_set_components(min(params["n_pca_components"],expression.shape[1]))

# calculate density
dens = pcreode.Density(pca_reduced_data)
best_guess = dens.radius_best_guess()
density = dens.get_density(radius = best_guess, mute=True)

# get downsampling parameters
noise, target = pcreode.get_thresholds( pca_reduced_data)

# run pCreode
out_graph, out_ids = pcreode.pCreode(
  data = pca_reduced_data,
Example #3
0
var_genes = np.loadtxt(fname='varGenes.txt', dtype='string')
col0 = normData_array[:, 0]
row_keep = (np.in1d(col0, var_genes) | (col0 == ''))
normData_subset = normData_array[row_keep, :]

normData_t = normData_subset.T
dim_normData_t = np.shape(normData_t)

my_data = normData_t[1:dim_normData_t[0] + 1,
                     1:dim_normData_t[1] + 1].astype('float')
my_index = normData_t[1:dim_normData_t[0] + 1, 0]
my_cols = normData_t[0, 1:dim_normData_t[1] + 1]

df = pd.DataFrame(data=my_data, index=my_index, columns=my_cols)

data_pca = pcreode.PCA(df)
data_pca.get_pca()

data_pca.pca_plot_explained_var(xlim=(0, 20))
exp_var_fname = 'sam_data_pca_exp_var'
plt.savefig(fname=exp_var_fname)

pca_test_data = data_pca.pca_set_components(20)

fig = plt.figure(figsize=(12, 12))
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)
cc = 'r'