Skip to content

Commit 1f7be83

Browse files
author
Sergio Salas
committed
adjust_docs2
1 parent 342b607 commit 1f7be83

6 files changed

Lines changed: 102 additions & 84 deletions

File tree

docs/.ipynb_checkpoints/index-checkpoint.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
```
44

55
```{toctree}
6-
:hidden: true
7-
:maxdepth: 1
6+
:maxdepth: 2
7+
:caption: API
88
9-
# API Reference
9+
api/preprocessing.md
10+
api/tools.md
11+
api/plotting.md
1012
11-
- [Preprocessing](api/preprocessing.md)
12-
- [Tools](api/tools.md)
13-
- [Plotting](api/plotting.md)
1413
1514
changelog.md
1615
contributing.md

docs/index.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
```
44

55
```{toctree}
6-
:hidden: true
7-
:maxdepth: 1
6+
:maxdepth: 2
7+
:caption: API
88
9-
# API Reference
9+
api/preprocessing.md
10+
api/tools.md
11+
api/plotting.md
1012
11-
- [Preprocessing](api/preprocessing.md)
12-
- [Tools](api/tools.md)
13-
- [Plotting](api/plotting.md)
1413
1514
changelog.md
1615
contributing.md

src/troutpy/tl/.ipynb_checkpoints/quantify_urna-checkpoint.py

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,25 @@ def spatial_variability(
108108
return sdata if copy else None
109109

110110

111-
def create_urna_metadata(sdata: SpatialData, layer: str = "transcripts", gene_key: str = "feature_name", copy: bool = False) -> SpatialData | None:
111+
def create_urna_metadata(sdata: spatialdata.SpatialData, layer: str = "transcripts", gene_key: str = "feature_name", copy: bool = False) -> spatialdata.SpatialData | None:
112112
"""
113113
Creates a new table within the SpatialData object that contains a 'gene' column with the unique gene names extracted from the specified points layer.
114114
115115
Parameters
116116
----------
117-
- sdata: spatialdata.SpatialData
117+
sdata: spatialdata.SpatialData
118118
The SpatialData object to modify.
119-
- layer: str
119+
layer: str
120120
The name of the layer in `sdata.points` from which to extract gene names. Default is 'transcripts'.
121-
- gene_key: str
121+
gene_key: str
122122
The key in the `layer` dataframe that contains the gene names.Default is 'feature_name'.
123-
- copy
124-
If `True`, returns a copy of the `SpatialData` object with the new table added.
123+
copy
124+
If `True`, returns a copy of the `spatialdata.SpatialData` object with the new table added.
125125
126126
Returns
127127
-------
128-
- SpatialData | None
129-
If `copy` is `True`, returns a copy of the modified `SpatialData` object. Otherwise, returns `None`.
128+
SpatialData | None
129+
If `copy` is `True`, returns a copy of the modified `spatialdata.SpatialData` object. Otherwise, returns `None`.
130130
"""
131131
# Check if the specified points layer exists
132132
if layer not in sdata.points:
@@ -462,10 +462,14 @@ def assess_diffusion(sdata: SpatialData, gene_key: str = "gene", distance_key: s
462462
463463
Parameters
464464
----------
465-
sdata (SpatialData): The spatial transcriptomics dataset.
466-
gene_key (str): The key for gene/transcript names in source_score.obs.
467-
distance_key (str): The key for RNA displacement distances.
468-
copy (bool): Whether to return a modified copy of sdata.
465+
sdata: spatialdata.SpatialData
466+
The spatial transcriptomics dataset.
467+
gene_key: str
468+
The key for gene/transcript names in source_score.obs.
469+
distance_key: str
470+
The key for RNA displacement distances.
471+
copy: bool
472+
Whether to return a modified copy of sdata.
469473
470474
Returns
471475
-------
@@ -534,24 +538,24 @@ def cluster_distribution_from_source(
534538
535539
Parameters
536540
----------
537-
sdata : SpatialData
541+
sdata : spatialdata.SpatialData
538542
Spatial data object containing a 'source_score' layer with an obs DataFrame.
539-
gene_key : str, default "feature_name"
543+
gene_key : str
540544
Column name that contains the gene names.
541-
distance_key : str, default "distance"
545+
distance_key : str
542546
Column name that contains the distance from the source cell.
543-
n_clusters : int, default 3
547+
n_clusters : int
544548
Number of clusters to form.
545-
n_bins : int, default 20
549+
n_bins : int
546550
Number of bins for the histogram representation.
547551
548552
Returns
549553
-------
550-
gene_cluster_df : DataFrame
554+
gene_cluster_df : pandas.DataFrame
551555
A DataFrame with columns 'gene' and 'cluster' indicating the cluster assignment.
552-
hist_df : DataFrame
556+
hist_df : pandas.DataFrame
553557
A DataFrame where each row is a gene and the columns are the normalized histogram counts.
554-
bin_edges : ndarray
558+
bin_edges : numpy.array
555559
The bin edges used for the histograms.
556560
"""
557561
# Get the observation DataFrame from the 'source_score' layer.
@@ -619,12 +623,18 @@ def compare_intra_extra_distribution(
619623
620624
Parameters
621625
----------
622-
- sdata: SpatialData object containing transcript locations and metadata.
623-
- layer: str, layer within sdata.points where transcripts are stored (default: "transcripts").
624-
- gene_key: str, column name where the gene name is stored (default: "feature_name").
625-
- copy: bool, whether to return a modified copy of sdata (default: False).
626-
- coord_keys: list of str, column names containing x and y transcript positions (default: ["x", "y"]).
627-
- n_bins: int, number of bins for the 2D histograms (default: 30).
626+
sdata: spatialdata.SpatialData
627+
SpatialData object containing transcript locations and metadata.
628+
layer: str
629+
Layer within sdata.points where transcripts are stored (default: "transcripts").
630+
gene_key: str
631+
Column name where the gene name is stored (default: "feature_name").
632+
copy: bool
633+
Whether to return a modified copy of sdata (default: False).
634+
coord_keys: list
635+
Column names containing x and y transcript positions (default: ["x", "y"]).
636+
n_bins: int
637+
Number of bins for the 2D histograms (default: 30).
628638
629639
Returns
630640
-------

src/troutpy/tl/.ipynb_checkpoints/source_cell-checkpoint.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,31 @@ def distance_to_source_cell(
123123
124124
Parameters
125125
----------
126-
- sdata: spatialdata.SpatialData
126+
sdata: spatialdata.SpatialData
127127
The AnnData object containing both transcript and cellular data.
128-
- layer: str
128+
layer: str
129129
The layer in `sdata` containing the transcript data. Default is 'transcripts'.
130-
- xcoord: str
130+
xcoord: str
131131
The column name in the transcript data for the x-coordinate. Default is 'x'.
132-
- ycoord: str
132+
ycoord: str
133133
The column name in the transcript data for the y-coordinate. Default is 'y'.
134-
- xcellcoord: str
134+
xcellcoord: str
135135
The column name in the cellular data for the x-coordinate of cell centroids. Default is 'x_centroid'.
136-
- ycellcoord: str
136+
ycellcoord: str
137137
The column name in the cellular data for the y-coordinate of cell centroids. Default is 'y_centroid'.
138-
- gene_key: str
138+
gene_key: str
139139
The column name for the gene identifier. Default is 'feature_name'.
140-
- copy: str
140+
copy: str
141141
Whether to return a copy of the `sdata` object with updated distances, or modify in place. Default is False.
142142
143143
Returns
144144
-------
145-
- AnnData or None: anndata.AnnData
145+
AnnData or None: anndata.AnnData
146146
If `copy` is True, returns the updated `sdata` object. Otherwise, modifies `sdata` in place and returns None.
147147
148148
Notes
149149
-----
150-
- The function assumes that the transcript data contains a column `transcript_id` and that the cellular data contains cell centroids for spatial coordinates. The KDTree algorithm is used to compute the closest cell for each transcript. The resulting distances are stored in the `distance_to_source_cell` column of the `sdata` object's transcript layer, and the closest source cell is stored in the `closest_source_cell` column. The median distance for each gene is also added to the `xrna_metadata` in the `var` attribute of `sdata`.
150+
The function assumes that the transcript data contains a column `transcript_id` and that the cellular data contains cell centroids for spatial coordinates. The KDTree algorithm is used to compute the closest cell for each transcript. The resulting distances are stored in the `distance_to_source_cell` column of the `sdata` object's transcript layer, and the closest source cell is stored in the `closest_source_cell` column. The median distance for each gene is also added to the `xrna_metadata` in the `var` attribute of `sdata`.
151151
"""
152152
# Extract transcript and cellular data
153153
adata_bin = sdata["table"].copy()

src/troutpy/tl/quantify_urna.py

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,25 @@ def spatial_variability(
108108
return sdata if copy else None
109109

110110

111-
def create_urna_metadata(sdata: SpatialData, layer: str = "transcripts", gene_key: str = "feature_name", copy: bool = False) -> SpatialData | None:
111+
def create_urna_metadata(sdata: spatialdata.SpatialData, layer: str = "transcripts", gene_key: str = "feature_name", copy: bool = False) -> spatialdata.SpatialData | None:
112112
"""
113113
Creates a new table within the SpatialData object that contains a 'gene' column with the unique gene names extracted from the specified points layer.
114114
115115
Parameters
116116
----------
117-
- sdata: spatialdata.SpatialData
117+
sdata: spatialdata.SpatialData
118118
The SpatialData object to modify.
119-
- layer: str
119+
layer: str
120120
The name of the layer in `sdata.points` from which to extract gene names. Default is 'transcripts'.
121-
- gene_key: str
121+
gene_key: str
122122
The key in the `layer` dataframe that contains the gene names.Default is 'feature_name'.
123-
- copy
124-
If `True`, returns a copy of the `SpatialData` object with the new table added.
123+
copy
124+
If `True`, returns a copy of the `spatialdata.SpatialData` object with the new table added.
125125
126126
Returns
127127
-------
128-
- SpatialData | None
129-
If `copy` is `True`, returns a copy of the modified `SpatialData` object. Otherwise, returns `None`.
128+
SpatialData | None
129+
If `copy` is `True`, returns a copy of the modified `spatialdata.SpatialData` object. Otherwise, returns `None`.
130130
"""
131131
# Check if the specified points layer exists
132132
if layer not in sdata.points:
@@ -462,10 +462,14 @@ def assess_diffusion(sdata: SpatialData, gene_key: str = "gene", distance_key: s
462462
463463
Parameters
464464
----------
465-
sdata (SpatialData): The spatial transcriptomics dataset.
466-
gene_key (str): The key for gene/transcript names in source_score.obs.
467-
distance_key (str): The key for RNA displacement distances.
468-
copy (bool): Whether to return a modified copy of sdata.
465+
sdata: spatialdata.SpatialData
466+
The spatial transcriptomics dataset.
467+
gene_key: str
468+
The key for gene/transcript names in source_score.obs.
469+
distance_key: str
470+
The key for RNA displacement distances.
471+
copy: bool
472+
Whether to return a modified copy of sdata.
469473
470474
Returns
471475
-------
@@ -534,24 +538,24 @@ def cluster_distribution_from_source(
534538
535539
Parameters
536540
----------
537-
sdata : SpatialData
541+
sdata : spatialdata.SpatialData
538542
Spatial data object containing a 'source_score' layer with an obs DataFrame.
539-
gene_key : str, default "feature_name"
543+
gene_key : str
540544
Column name that contains the gene names.
541-
distance_key : str, default "distance"
545+
distance_key : str
542546
Column name that contains the distance from the source cell.
543-
n_clusters : int, default 3
547+
n_clusters : int
544548
Number of clusters to form.
545-
n_bins : int, default 20
549+
n_bins : int
546550
Number of bins for the histogram representation.
547551
548552
Returns
549553
-------
550-
gene_cluster_df : DataFrame
554+
gene_cluster_df : pandas.DataFrame
551555
A DataFrame with columns 'gene' and 'cluster' indicating the cluster assignment.
552-
hist_df : DataFrame
556+
hist_df : pandas.DataFrame
553557
A DataFrame where each row is a gene and the columns are the normalized histogram counts.
554-
bin_edges : ndarray
558+
bin_edges : numpy.array
555559
The bin edges used for the histograms.
556560
"""
557561
# Get the observation DataFrame from the 'source_score' layer.
@@ -619,12 +623,18 @@ def compare_intra_extra_distribution(
619623
620624
Parameters
621625
----------
622-
- sdata: SpatialData object containing transcript locations and metadata.
623-
- layer: str, layer within sdata.points where transcripts are stored (default: "transcripts").
624-
- gene_key: str, column name where the gene name is stored (default: "feature_name").
625-
- copy: bool, whether to return a modified copy of sdata (default: False).
626-
- coord_keys: list of str, column names containing x and y transcript positions (default: ["x", "y"]).
627-
- n_bins: int, number of bins for the 2D histograms (default: 30).
626+
sdata: spatialdata.SpatialData
627+
SpatialData object containing transcript locations and metadata.
628+
layer: str
629+
Layer within sdata.points where transcripts are stored (default: "transcripts").
630+
gene_key: str
631+
Column name where the gene name is stored (default: "feature_name").
632+
copy: bool
633+
Whether to return a modified copy of sdata (default: False).
634+
coord_keys: list
635+
Column names containing x and y transcript positions (default: ["x", "y"]).
636+
n_bins: int
637+
Number of bins for the 2D histograms (default: 30).
628638
629639
Returns
630640
-------

src/troutpy/tl/source_cell.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,31 @@ def distance_to_source_cell(
123123
124124
Parameters
125125
----------
126-
- sdata: spatialdata.SpatialData
126+
sdata: spatialdata.SpatialData
127127
The AnnData object containing both transcript and cellular data.
128-
- layer: str
128+
layer: str
129129
The layer in `sdata` containing the transcript data. Default is 'transcripts'.
130-
- xcoord: str
130+
xcoord: str
131131
The column name in the transcript data for the x-coordinate. Default is 'x'.
132-
- ycoord: str
132+
ycoord: str
133133
The column name in the transcript data for the y-coordinate. Default is 'y'.
134-
- xcellcoord: str
134+
xcellcoord: str
135135
The column name in the cellular data for the x-coordinate of cell centroids. Default is 'x_centroid'.
136-
- ycellcoord: str
136+
ycellcoord: str
137137
The column name in the cellular data for the y-coordinate of cell centroids. Default is 'y_centroid'.
138-
- gene_key: str
138+
gene_key: str
139139
The column name for the gene identifier. Default is 'feature_name'.
140-
- copy: str
140+
copy: str
141141
Whether to return a copy of the `sdata` object with updated distances, or modify in place. Default is False.
142142
143143
Returns
144144
-------
145-
- AnnData or None: anndata.AnnData
145+
AnnData or None: anndata.AnnData
146146
If `copy` is True, returns the updated `sdata` object. Otherwise, modifies `sdata` in place and returns None.
147147
148148
Notes
149149
-----
150-
- The function assumes that the transcript data contains a column `transcript_id` and that the cellular data contains cell centroids for spatial coordinates. The KDTree algorithm is used to compute the closest cell for each transcript. The resulting distances are stored in the `distance_to_source_cell` column of the `sdata` object's transcript layer, and the closest source cell is stored in the `closest_source_cell` column. The median distance for each gene is also added to the `xrna_metadata` in the `var` attribute of `sdata`.
150+
The function assumes that the transcript data contains a column `transcript_id` and that the cellular data contains cell centroids for spatial coordinates. The KDTree algorithm is used to compute the closest cell for each transcript. The resulting distances are stored in the `distance_to_source_cell` column of the `sdata` object's transcript layer, and the closest source cell is stored in the `closest_source_cell` column. The median distance for each gene is also added to the `xrna_metadata` in the `var` attribute of `sdata`.
151151
"""
152152
# Extract transcript and cellular data
153153
adata_bin = sdata["table"].copy()

0 commit comments

Comments
 (0)