Skip to content

Commit

Permalink
New tutorial. Fixed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbernstein committed Aug 23, 2023
1 parent 9f9b9b3 commit 3622d20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
20 changes: 10 additions & 10 deletions docs/notebooks/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@
"id": "9d57a683",
"metadata": {},
"source": [
"# Niche analysis\n",
"## Niche analysis\n",
"\n",
"We now demonstrate how to perform an analysis of cellular niches. Specifically, for each cell, we count the number of neighbors that are of each cell type thus forming a \"neighborhood profile\" vector of length C, where C is the number of cell types. We then cluster all neighborhood profiles and call each cluster a \"niche\".\n",
"\n",
Expand Down Expand Up @@ -1274,11 +1274,11 @@
"id": "0f2ad69e",
"metadata": {},
"source": [
"# Comparing gene expression between niches\n",
"## Comparing gene expression between niches\n",
"\n",
"Next we'll show how the niche annotation can be further explored by examining changes in gene expression between these niches\n",
"\n",
"## Visualizing gene expression differences\n",
"### Visualizing gene expression differences\n",
"\n",
"Below we zoom on a specific region of the specimen and color each cell by their expression of CXCL9 and CXCL10, two genes that are up-regulated in response to interferon."
]
Expand Down Expand Up @@ -1394,7 +1394,7 @@
"id": "3d0c4eb8",
"metadata": {},
"source": [
"## Differential expression analysis between cells in different niches\n",
"### Differential expression analysis between cells in different niches\n",
"\n",
"Here we demonstrate how to use Scanpy to perform differential expression analysis between cells in different niches. Specifically, we will perform a DE analysis between T cells in Niches 4 and 2. We begin by isolating the T cells in these niches."
]
Expand Down Expand Up @@ -1492,9 +1492,9 @@
"id": "23afca4e",
"metadata": {},
"source": [
"# Exploration of co-localization between cell types\n",
"## Exploration of co-localization between cell types\n",
"\n",
"## Visualization of neighboring cells\n",
"### Visualization of neighboring cells\n",
"\n",
"Here we compute a mapping of each cell of a given cell type to all neighboring cells within a specified radius. Here we identify all CD4 T cell neighbors of each dendritic cell (mregDC). Notice, each argument is a list denoting a union of cell types. Here we identify all neighbors of mature regulatory DCs (mregDCs), conventional DCs, and pDCs that are CD4 T cells."
]
Expand Down Expand Up @@ -1887,7 +1887,7 @@
"id": "4bc79fcb",
"metadata": {},
"source": [
"# Ligand-receptor analysis"
"## Ligand-receptor analysis"
]
},
{
Expand Down Expand Up @@ -2158,7 +2158,7 @@
},
{
"cell_type": "markdown",
"id": "193d5937",
"id": "f55f230d",
"metadata": {},
"source": [
"To summarize the results, we can plot the p-value vs. the score itself. To do so, we call `ligand_receptor_scatter` and pass the observed scores, `lr_pair_to_score`, and the results from the permutation test stored in `res`. "
Expand All @@ -2167,7 +2167,7 @@
{
"cell_type": "code",
"execution_count": 55,
"id": "2721c9d9",
"id": "cfa21182",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -2441,7 +2441,7 @@
},
{
"cell_type": "markdown",
"id": "347c6136",
"id": "922c87c7",
"metadata": {},
"source": [
"Lastly, we can plot the ligand-receptor co-expression score for multiple ligand receptors using a heatmap. By setting `z_score=True`, we plot the z-score normalized scores, where the z-score is computed for each ligand/receptor pair over the niches. The parameter `clip_z=2` clips the maximum and minimum z-scores to 2 and -2 (i.e., 2 and -2 standard deviations from the mean)."
Expand Down
12 changes: 5 additions & 7 deletions src/monkeybread/calc/_ligand_receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,10 @@ def ligand_receptor_score_per_niche(
"""
Calculates an average co-expression score of a
ligand-receptor pair between neighboring cells within each cellular niche
calculated by :func:`monkeybread.calc.cellular_niches`.
Statistical test is as described in :cite:p:`He2021.11.03.467020` (See
Figure 4).
This function is a wrapper around :func:`monkeybread.calc.ligand_receptor_score`
and calls this function separately for each niche.
calculated by :func:`monkeybread.calc.cellular_niches`. Statistical test is as described
in :cite:p:`He2021.11.03.467020` (See Figure 4). This function is a wrapper around
:func:`monkeybread.calc.ligand_receptor_score` and calls this function separately for
each niche.
Parameters
----------
Expand All @@ -115,6 +112,7 @@ def ligand_receptor_score_per_niche(
A dictionary mapping each niche to a sub-dictionary mapping each ligand-receptor
pair to its co-expression score.
"""

niche_to_lr_pair_to_score = {}
for niche, cell_to_neighbors in niche_to_cell_to_neighbors.items():

Expand Down

0 comments on commit 3622d20

Please sign in to comment.