Skip to content

Commit

Permalink
notebooks_mod2
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomarco25 committed Dec 18, 2024
1 parent 98e0a84 commit 8c0b035
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 2,904 deletions.
1,049 changes: 0 additions & 1,049 deletions notebooks/spatialdata_tutorials/10_apply_sc_signatures_to_exrna.ipynb

This file was deleted.

14 changes: 7 additions & 7 deletions notebooks/spatialdata_tutorials/1_run_segmentation_free.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -12,7 +12,7 @@
"import spatialdata_plot\n",
"import sys\n",
"sys.path.append(\"../../src\")\n",
"import troutpy \n"
"import troutpy "
]
},
{
Expand Down Expand Up @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -84,7 +84,7 @@
"#define points2regions_params\n",
"points2regions_params={'num_clusters':100, 'pixel_width':0.4, 'pixel_smoothing':3.5}\n",
"#run_segmentation_free\n",
"exrna.tl.segmentation_free_clustering(sdata, params=points2regions_params, \n",
"troutpy.tl.segmentation_free_clustering(sdata, params=points2regions_params, \n",
" x='x', y='y', feature_name='feature_name', transcript_id='transcript_id')"
]
},
Expand All @@ -97,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -110,7 +110,7 @@
}
],
"source": [
"exrna.pp.define_extracellular(sdata, method='segmentation_free',min_prop_of_extracellular=0.8) "
"troutpy.pp.define_extracellular(sdata, method='segmentation_free',min_prop_of_extracellular=0.8) "
]
},
{
Expand Down Expand Up @@ -190,7 +190,7 @@
"\n",
"\n",
"input_data=sdata.points['transcripts'][['missegmentation_associated']].compute()\n",
"exrna.pl.pie_of_positive(input_data,groupby='missegmentation_associated',figures_path=output_path,save=True)"
"troutpy.pl.pie_of_positive(input_data,groupby='missegmentation_associated',figures_path=output_path,save=True)"
]
}
],
Expand Down
16 changes: 8 additions & 8 deletions notebooks/spatialdata_tutorials/3_quantify_exRNA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -111,7 +111,7 @@
"control_codewords = ['negative_control_probe','unassigned_codeword', 'deprecated_codeword', \n",
" 'genomic_control_probe', 'negative_control_codeword']\n",
"\n",
"exrna.tl.quantify_overexpression(sdata,layer='transcripts',codeword_column=\"codeword_category\",\n",
"troutpy.tl.quantify_overexpression(sdata,layer='transcripts',codeword_column=\"codeword_category\",\n",
" control_codewords=control_codewords,gene_id_column=\"feature_name\",percentile_threshold=99.99)\n"
]
},
Expand All @@ -124,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -137,7 +137,7 @@
}
],
"source": [
"exrna.tl.extracellular_enrichment(sdata)"
"troutpy.tl.extracellular_enrichment(sdata)"
]
},
{
Expand All @@ -149,7 +149,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -161,7 +161,7 @@
}
],
"source": [
"exrna.tl.spatial_variability(sdata, gene_id_key='feature_name', n_neighbors=10,binsize=20)"
"troutpy.tl.spatial_variability(sdata, gene_id_key='feature_name', n_neighbors=10,binsize=20)"
]
},
{
Expand All @@ -173,7 +173,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -185,7 +185,7 @@
}
],
"source": [
"exrna.tl.spatial_colocalization(sdata, coords_keys=['x', 'y'], gene_id_key='feature_name',resolution=1000,binsize=5, threshold_colocalized=1 ,copy=False)"
"troutpy.tl.spatial_colocalization(sdata, coords_keys=['x', 'y'], gene_id_key='feature_name',resolution=1000,binsize=5, threshold_colocalized=1 ,copy=False)"
]
},
{
Expand Down
32 changes: 16 additions & 16 deletions notebooks/spatialdata_tutorials/4_explore_comunication.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -87,20 +87,20 @@
}
],
"source": [
"exrna.tl.compute_source_cells(sdata, expression_threshold=0)"
"troutpy.tl.compute_source_cells(sdata, expression_threshold=0)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# work on visualization\n",
"#filtered_proportions = source_proportion[(source_proportion > 0.1).any(axis=1)]\n",
"#absent_source_proportions = source_proportion[np.max(source_proportion,axis=1)<0.1]\n",
"#exrna.pl.sorted_heatmap(source_proportion, output_path,filename=\"Heatmap_source_cells_by_gene.pdf\",cmap='Blues',vmax=0.2)\n",
"#exrna.pl.sorted_heatmap(absent_source_proportions, output_path,filename=\"Heatmap_source_cells_by_gene.pdf\",cmap='Blues',vmax=1,figsize=(4,3))"
"#troutpy.pl.sorted_heatmap(source_proportion, output_path,filename=\"Heatmap_source_cells_by_gene.pdf\",cmap='Blues',vmax=0.2)\n",
"#troutpy.pl.sorted_heatmap(absent_source_proportions, output_path,filename=\"Heatmap_source_cells_by_gene.pdf\",cmap='Blues',vmax=1,figsize=(4,3))"
]
},
{
Expand All @@ -124,7 +124,7 @@
}
],
"source": [
"exrna.tl.distance_to_source_cell(sdata, xcellcoord='x_centroid', ycellcoord='y_centroid',gene_id_column='feature_name')"
"troutpy.tl.distance_to_source_cell(sdata, xcellcoord='x_centroid', ycellcoord='y_centroid',gene_id_column='feature_name')"
]
},
{
Expand All @@ -142,7 +142,7 @@
}
],
"source": [
"exrna.tl.compute_distant_cells_prop(sdata, layer='transcripts', gene_id_column='feature_name', threshold=30,copy=False)"
"troutpy.tl.compute_distant_cells_prop(sdata, layer='transcripts', gene_id_column='feature_name', threshold=30,copy=False)"
]
},
{
Expand All @@ -152,7 +152,7 @@
"outputs": [],
"source": [
"## work on plotting\n",
"#exrna.pl.proportion_above_threshold(proportions_above_threshold, top_percentile=0.01, bottom_percentile=0.01, figsize=(5, 10), bar_color=\"orange\",save=True,output_path=output_path)"
"#troutpy.pl.proportion_above_threshold(proportions_above_threshold, top_percentile=0.01, bottom_percentile=0.01, figsize=(5, 10), bar_color=\"orange\",save=True,output_path=output_path)"
]
},
{
Expand Down Expand Up @@ -181,7 +181,7 @@
],
"source": [
"# Calculate closest cells and distances\n",
"exrna.tl.calculate_target_cells(sdata, layer='transcripts', xcoord='x', \n",
"troutpy.tl.calculate_target_cells(sdata, layer='transcripts', xcoord='x', \n",
"ycoord='y',xcellcoord='x_centroid',ycellcoord='y_centroid',celltype_key='cell type',copy=False)"
]
},
Expand All @@ -192,8 +192,8 @@
"outputs": [],
"source": [
"### work on plotting \n",
"##exrna.pl.sorted_heatmap(target_proportion, output_path,filename=\"Heatmap_target_cells_by_gene.pdf\",cmap='Reds',vmax=1)\n",
"#exrna.pl.coupled_scatter(sdata,layer='extracellular_transcripts_enriched',save=False,transcript_group='distance_to_source_cell',size=3,vmax=40,figsize=(6,4))"
"##troutpy.pl.sorted_heatmap(target_proportion, output_path,filename=\"Heatmap_target_cells_by_gene.pdf\",cmap='Reds',vmax=1)\n",
"#troutpy.pl.coupled_scatter(sdata,layer='extracellular_transcripts_enriched',save=False,transcript_group='distance_to_source_cell',size=3,vmax=40,figsize=(6,4))"
]
},
{
Expand Down Expand Up @@ -304,7 +304,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -319,7 +319,7 @@
}
],
"source": [
"exrna.pl.sorted_heatmap(communications_ngenes.astype(float),save=False,figsize=(5,5))"
"troutpy.pl.sorted_heatmap(communications_ngenes.astype(float),save=False,figsize=(5,5))"
]
},
{
Expand All @@ -340,7 +340,7 @@
],
"source": [
"# Is this a plotting function?\n",
"interactions_Vxn=exrna.tl.get_gene_interaction_strength(source_proportion, target_proportion,gene_symbol=\"Gfap\")"
"interactions_Vxn=troutpy.tl.get_gene_interaction_strength(source_proportion, target_proportion,gene_symbol=\"Gfap\")"
]
},
{
Expand Down Expand Up @@ -368,7 +368,7 @@
}
],
"source": [
"exrna.pl.spatial_interactions(sdata,layer= 'extracellular_transcripts_enriched', gene = 'Arc',gene_key= 'feature_name',figsize=(5,5))"
"troutpy.pl.spatial_interactions(sdata,layer= 'extracellular_transcripts_enriched', gene = 'Arc',gene_key= 'feature_name',figsize=(5,5))"
]
},
{
Expand Down Expand Up @@ -396,7 +396,7 @@
}
],
"source": [
"exrna.pl.interactions_with_arrows(sdata,layer= 'extracellular_transcripts_enriched', gene = 'Kif5a',gene_key= 'feature_name',figsize=(7,7),dpi=100,size=5)"
"troutpy.pl.interactions_with_arrows(sdata,layer= 'extracellular_transcripts_enriched', gene = 'Kif5a',gene_key= 'feature_name',figsize=(7,7),dpi=100,size=5)"
]
}
],
Expand Down
14 changes: 7 additions & 7 deletions notebooks/spatialdata_tutorials/6_identify_patterns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sdata=exrna.tl.nmf(sdata, layer='extracellular_transcripts', feature_key='feature_name', bin_key='bin_id', \n",
"sdata=troutpy.tl.nmf(sdata, layer='extracellular_transcripts', feature_key='feature_name', bin_key='bin_id', \n",
" density_table_key='segmentation_free_table', n_components=10, subsample_percentage=0.1,all=False)"
]
},
Expand All @@ -89,12 +89,12 @@
"outputs": [],
"source": [
"## in this part we plot the factors in exrna\n",
"#exrna.pl.nmf_factors_exrna_cells_W(sdata,nmf_adata_key,saving_path=output_path,save=False,spot_size=5) "
"#troutpy.pl.nmf_factors_exrna_cells_W(sdata,nmf_adata_key,saving_path=output_path,save=False,spot_size=5) "
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -109,7 +109,7 @@
}
],
"source": [
"exrna.pl.nmf_gene_contributions(sdata,nmf_adata_key='nmf_data', vmin=0.0, vmax=0.02,saving_path=output_path,save=False,figsize=(4,5))"
"troutpy.pl.nmf_gene_contributions(sdata,nmf_adata_key='nmf_data', vmin=0.0, vmax=0.02,saving_path=output_path,save=False,figsize=(4,5))"
]
},
{
Expand All @@ -136,7 +136,7 @@
}
],
"source": [
"sdata = exrna.tl.apply_exrna_factors_to_cells(sdata,layer_factors='nmf_data')"
"sdata = troutpy.tl.apply_exrna_factors_to_cells(sdata,layer_factors='nmf_data')"
]
},
{
Expand Down Expand Up @@ -246,7 +246,7 @@
}
],
"source": [
"exrna.pl.paired_nmf_factors(sdata,figsize=(7,7),n_factors=10)"
"troutpy.pl.paired_nmf_factors(sdata,figsize=(7,7),n_factors=10)"
]
}
],
Expand Down
20 changes: 0 additions & 20 deletions notebooks/spatialdata_tutorials/7_image_params.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,6 @@
"plt.scatter(transcripts.x_scaled,transcripts.y_scaled,s=0.01,color='red')"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(5, 3000, 5000)"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"imarray.shape"
]
},
{
"cell_type": "code",
"execution_count": 66,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/spatialdata_tutorials/8_exrna_signature.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -26,7 +26,7 @@
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"import spatialdata_io\n",
"import spatialdata as sd\n"
"import spatialdata as sd"
]
},
{
Expand Down
Loading

0 comments on commit 8c0b035

Please sign in to comment.