Skip to content

Commit

Permalink
update_icml
Browse files Browse the repository at this point in the history
  • Loading branch information
agarwala95 committed May 22, 2020
1 parent 236d854 commit 9db436e
Show file tree
Hide file tree
Showing 65 changed files with 16,648 additions and 96 deletions.
122 changes: 106 additions & 16 deletions JN1_train.ipynb

Large diffs are not rendered by default.

60 changes: 29 additions & 31 deletions JN2_kang_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/icb/harshita.agarwala/miniconda3/envs/tf_gpu/lib/python3.7/site-packages/anndata/_core/anndata.py:21: FutureWarning: pandas.core.index is deprecated and will be removed in a future version. The public classes are available in the top-level namespace.\n",
" from pandas.core.index import RangeIndex\n",
"Using TensorFlow backend.\n"
]
"name": "stderr",
"text": "Using TensorFlow backend.\n"
}
],
"source": [
Expand All @@ -31,7 +27,8 @@
"import sys\n",
"import util_loss as ul\n",
"#import the package to use\n",
"import beta_vae_5\n",
"import beta_vae\n",
"import dhsic_vae\n",
"from seurat_features import *\n",
"from all_obs_linear_classifier_package import *\n",
"import os,glob"
Expand Down Expand Up @@ -112,9 +109,9 @@
"Difference scores between features are calculated: 1st level\n",
"'''\n",
"# Restoring pre-trained models\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")\n",
"os.chdir(\"/models_kang/\")\n",
"path = \"latent5_alpha5_c30\"\n",
"scg_model = beta_vae_5.C_VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
"scg_model = beta_vae.VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
" alpha=5,c_max=30)\n",
"scg_model.restore_model()\n",
"print(scg_model)\n",
Expand All @@ -131,7 +128,7 @@
" print (\"Successfully created the directory \", path+observation+\"_disentangled_score/\")\n",
"\n",
"for i in range(5):\n",
" df = feature_scores(model=scg_model,L=L,B=B,data=data)\n",
" df = feature_scores(model=scg_model,L=L,B=B,data=data) #function from seurat_features.py\n",
" print(df)\n",
" df.to_csv(path+observation+\"_disentangled_score/matrix_all_dim\"+str(i)+\".csv\",index=False)"
]
Expand All @@ -145,10 +142,10 @@
"'''\n",
"Difference scores between features are are now classified\n",
"'''\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")\n",
"os.chdir(\"/models_kang/\")\n",
"path = \"latent5_alpha5_c30\"\n",
"observation=\"4_observation\"\n",
"feature_classification(path=path,z_dim = 5,observation=observation)"
"feature_classification(path=path,z_dim = 5,observation=observation) #function from all_obs_linear_classifier_package.py"
]
},
{
Expand All @@ -158,14 +155,14 @@
"outputs": [],
"source": [
"'''\n",
"Creating latent space plots for each feature and also \n",
"saving the latent space values for each feature\n",
"Creating latent representation plots for each feature's distribution.\n",
"Also saving the latent space values for each feature\n",
"'''\n",
"\n",
"from convert_to_latent_space import *\n",
"\n",
"observations = [\"cell_type\",\"condition\",\"exp_gene\",\"seq_depth\"]\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")\n",
"os.chdir(\"/models_kang/\")\n",
"path = \"latent5_alpha5_c30/\"\n",
"\n",
"scg_model = beta_vae_5.C_VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
Expand All @@ -174,7 +171,7 @@
"\n",
"for obs in observations: \n",
" single_feature_to_latent(path=path,adata=data,feature=obs,model=scg_model,z_dim=5)\n",
" os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")"
" os.chdir(\"/models_kang/\")"
]
},
{
Expand All @@ -187,7 +184,7 @@
"Difference scores within features are calculated: 2nd level\n",
"'''\n",
"from latent_space_scores import *\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")\n",
"os.chdir(\"/models_kang/\")\n",
"path = \"latent5_alpha5_c30/\"\n",
"\n",
"observation = \"cell_type\" #feature name to identify the score files\n",
Expand Down Expand Up @@ -219,10 +216,11 @@
"'''\n",
"Latent Space scores within feature is now classified\n",
"'''\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")\n",
"os.chdir(\"/models_kang/\")\n",
"path = \"latent5_alpha5_c30/\"\n",
"observation=\"4_observation\"\n",
"feature_classification(path=path,z_dim = 5,observation=\"cell_type\") #keep changing the observation"
"observations = [\"cell_type\",\"condition\",\"exp_gene\",\"seq_depth\"]\n",
"for obs in observations:\n",
" feature_classification(path=path,z_dim = 5,observation=obs) #keep changing the observation"
]
},
{
Expand Down Expand Up @@ -475,11 +473,11 @@
"Creating latent space plots for 2 features: Only for Kang Dataset\n",
"Cell Type and Condition together\n",
"'''\n",
"from latent_space_plots_seurat import *\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")\n",
"from latent_space_plots_kang import *\n",
"os.chdir(\"/models_kang/\")\n",
"path = \"latent5_alpha5_c30/\"\n",
"\n",
"scg_model = beta_vae_5.C_VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
"scg_model = beta_vae.VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
" alpha=5,c_max=30)\n",
"scg_model.restore_model()\n",
"\n",
Expand Down Expand Up @@ -509,7 +507,7 @@
"'''\n",
"from kl_divergence_plot import *\n",
"\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")\n",
"os.chdir(\"/models_kang/\")\n",
"path = \"latent5_alpha5_c30/\"\n",
"plot_kl_loss(path=path,z_dim=5)\n"
]
Expand Down Expand Up @@ -548,10 +546,10 @@
"Only for Kang dataset. Disentanglement between 'condition' and 'cell_type'\n",
"'''\n",
"from simulate_cell import *\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs\")\n",
"os.chdir(\"/models_kang/\")\n",
"path = \"latent5_alpha5_c30/\"\n",
"\n",
"scg_model = beta_vae_5.C_VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
"scg_model = beta_vae.VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
" alpha=5,c_max=30)\n",
"scg_model.restore_model()\n",
"\n",
Expand Down Expand Up @@ -695,7 +693,7 @@
" \"CTRL\": ['IL8', 'CD14', 'GAPDH'],\n",
" \"STIM\":['ISG15', 'IFI6', 'ISG20']}\n",
"\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_seurat_1000epochs/latent5_alpha5_c30/gene_heatmaps/\")\n",
"os.chdir(\"/models_kang/\")\n",
"file_list = os.listdir()\n",
"print(file_list)\n",
"for file in file_list:\n",
Expand All @@ -713,9 +711,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.7.5 64-bit ('disentangled': conda)",
"language": "python",
"name": "python3"
"name": "python37564bitdisentangledcondadf3ced1978944ed4ad778b28405fa6a7"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -727,9 +725,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.5-final"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
}
45 changes: 29 additions & 16 deletions JN3_dentate_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": "Using TensorFlow backend.\n"
}
],
"source": [
"import scanpy as sc\n",
"import pandas as pd\n",
Expand All @@ -21,17 +27,24 @@
"import sys\n",
"import util_loss as ul\n",
"#import the package to use\n",
"import beta_vae_5\n",
"import beta_vae\n",
"import dhsic_vae\n",
"from dentate_features import *\n",
"from all_obs_linear_classifier_package import *\n",
"import os,glob"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "clusters age(days) clusters_enlarged \\\nindex \nAAACATACCCATGA Granule immature 35 Granule-immature \nAAACATACCGTAGT Radial Glia-like 12 Radial Glia-like \nAAACATACGAGAGC Granule mature 35 Granule-mature \nAAACATACTGAGGG Granule immature 12 Granule-immature \nAAACATTGGCATCA Granule immature 35 Granule-immature \n... ... ... ... \nTTTCTACTTCCCGT Granule immature 35 Granule-immature \nTTTGACTGCCTGTC Neuroblast 12 Neuroblast 2 \nTTTGACTGTCTGGA Granule mature 35 Granule-mature \nTTTGCATGGGAGTG Microglia 35 Microglia \nTTTGCATGTTCTTG Granule immature 35 Granule-immature \n\n initial_size_unspliced initial_size_spliced initial_size \\\nindex \nAAACATACCCATGA 434.0 2870.0 2870.0 \nAAACATACCGTAGT 118.0 2367.0 2367.0 \nAAACATACGAGAGC 140.0 1629.0 1629.0 \nAAACATACTGAGGG 419.0 4206.0 4206.0 \nAAACATTGGCATCA 320.0 2887.0 2887.0 \n... ... ... ... \nTTTCTACTTCCCGT 266.0 3313.0 3313.0 \nTTTGACTGCCTGTC 121.0 1584.0 1584.0 \nTTTGACTGTCTGGA 361.0 2019.0 2019.0 \nTTTGCATGGGAGTG 69.0 1084.0 1084.0 \nTTTGCATGTTCTTG 447.0 3427.0 3427.0 \n\n n_counts seq_depth exp_gene \nindex \nAAACATACCCATGA 1488.302368 7 3 \nAAACATACCGTAGT 1389.813354 5 2 \nAAACATACGAGAGC 1471.164429 5 1 \nAAACATACTGAGGG 1587.683594 7 4 \nAAACATTGGCATCA 1471.868164 6 3 \n... ... ... ... \nTTTCTACTTCCCGT 1555.915283 7 3 \nTTTGACTGCCTGTC 1545.579224 4 1 \nTTTGACTGTCTGGA 1516.028687 6 2 \nTTTGCATGGGAGTG 1409.566895 1 0 \nTTTGCATGTTCTTG 1569.493164 7 4 \n\n[2930 rows x 9 columns]\n"
}
],
"source": [
"data = sc.read(\"./data/dentate_gyrus_normalized.h5ad\")\n",
"\n",
Expand Down Expand Up @@ -66,9 +79,9 @@
"Difference scores between features are calculated: 1st level\n",
"'''\n",
"# Restoring pre-trained models\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_dentate_1000epochs\")\n",
"os.chdir(\"./models_dentate/\")\n",
"path = \"latent5_alpha50_c30/\"\n",
"scg_model = beta_vae_5.C_VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
"scg_model = beta_vae.VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,\n",
" alpha=5,c_max=30)\n",
"scg_model.restore_model()\n",
"print(scg_model)\n",
Expand Down Expand Up @@ -99,7 +112,7 @@
"'''\n",
"Difference scores between features are are now classified\n",
"'''\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_dentate_1000epochs\")\n",
"os.chdir(\"/models_dentate/\")\n",
"path = \"latent5_alpha50_c30/\"\n",
"observation=\"4_observation\"\n",
"feature_classification(path=path,z_dim = 5,observation=observation)"
Expand Down Expand Up @@ -237,10 +250,10 @@
"\n",
"from convert_to_latent_space import *\n",
"\n",
"observations = [\"age(days)\",\"clusters\",\"exp_gene\",\"seq_depth\"]\n",
"#observations = [\"age(days)\",\"clusters\",\"exp_gene\",\"seq_depth\"]\n",
"observations = [\"clusters\"]\n",
"\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_dentate_1000epochs\")\n",
"os.chdir(\"/models_dentate/\")\n",
"path = \"latent5_alpha50_c30/\"\n",
"\n",
"scg_model = beta_vae_5.C_VAEArithKeras(x_dimension= data.shape[1],z_dimension=5,model_to_use=path,\n",
Expand All @@ -249,7 +262,7 @@
"\n",
"for obs in observations: \n",
" single_feature_to_latent(path=path,adata=data,feature=obs,model=scg_model,z_dim=5)\n",
" os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_dentate_1000epochs\")"
" os.chdir(\"/models_dentate/\")"
]
},
{
Expand All @@ -263,7 +276,7 @@
"It depends on the function 'single_feature_to_latent' used in the previous section.\n",
"'''\n",
"from latent_space_scores import *\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_dentate_1000epochs\")\n",
"os.chdir(\"/models_dentate/\")\n",
"path = \"latent5_alpha50_c30/\"\n",
"\n",
"observation = \"clusters\" #feature name to identify the score files\n",
Expand Down Expand Up @@ -295,7 +308,7 @@
"'''\n",
"Latent Space scores within feature is now classified\n",
"'''\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_dentate_1000epochs\")\n",
"os.chdir(\"/models_dentate/\")\n",
"path = \"latent5_alpha50_c30/\"\n",
"\n",
"feature_classification(path=path,z_dim = 5,observation=\"clusters\") #keep changing the observation"
Expand Down Expand Up @@ -323,7 +336,7 @@
"'''\n",
"from kl_divergence_plot import *\n",
"\n",
"os.chdir(\"/storage/groups/ml01/workspace/harshita.agarwala/models_dentate_1000epochs\")\n",
"os.chdir(\"/models_dentate/\")\n",
"path = \"latent5_alpha50_c30/\"\n",
"plot_kl_loss(path=path,z_dim=5)\n"
]
Expand All @@ -345,9 +358,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.5-final"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
}
Loading

0 comments on commit 9db436e

Please sign in to comment.