Skip to content

Commit

Permalink
Merge pull request #76 from nf-core/gearyc
Browse files Browse the repository at this point in the history
Add Geary's C autocorrelation method for SVG report
  • Loading branch information
fasterius authored Apr 16, 2024
2 parents b882ba4 + d832412 commit d898c8f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
12 changes: 8 additions & 4 deletions bin/spatially_variable_genes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jupyter: python3
#| tags: [parameters]
#| echo: false
input_sdata = "sdata_processed.zarr" # Input: SpatialData file
svg_autocorr_method = "moran" # Parameter: SVG autocorrelation method
n_top_svgs = 14 # Number of spatially variable genes to plot
artifact_dir = "artifacts" # Output directory
output_csv = "spatially_variable_genes.csv" # Output: gene list
Expand Down Expand Up @@ -117,15 +118,18 @@ patterns. Here we use [Moran's I](https://en.wikipedia.org/wiki/Moran%27s_I) aut

```{python}
adata.var_names_make_unique()
sq.gr.spatial_autocorr(adata, mode="moran")
adata.uns["moranI"].head(n_top_svgs)
#[TODO] add gearyC as optional mode
sq.gr.spatial_autocorr(adata, mode=svg_autocorr_method)
if svg_autocorr_method == "moran":
svg_autocorr_method_string = "moranI"
else:
svg_autocorr_method_string = "gearyC"
adata.uns[svg_autocorr_method_string].head(n_top_svgs)
```

```{python}
#| echo: false
# Save the spatially variable genes to a CSV file:
adata.uns["moranI"].to_csv(os.path.join(artifact_dir, output_csv))
adata.uns[svg_autocorr_method_string].to_csv(os.path.join(artifact_dir, output_csv))
```

```{python}
Expand Down
2 changes: 1 addition & 1 deletion modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"nf-core": {
"fastqc": {
"branch": "master",
"git_sha": "f4ae1d942bd50c5c0b9bd2de1393ce38315ba57c",
"git_sha": "285a50500f9e02578d90b3ce6382ea3c30216acd",
"installed_by": ["modules"]
},
"multiqc": {
Expand Down
6 changes: 6 additions & 0 deletions modules/nf-core/fastqc/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ params {
cluster_resolution = 1.0

// Spatial differential expression
svg_autocorr_method = "moran"
n_top_svgs = 14

// MultiQC options
Expand Down
7 changes: 7 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@
"help_text": "The resolution controls the coarseness of the clustering, where a higher resolution leads to more clusters.",
"fa_icon": "fas fa-circle-nodes"
},
"svg_autocorr_method": {
"type": "string",
"default": "moran",
"description": "The method to use for spatially variable gene autocorrelation.",
"enum": ["moran", "geary"],
"fa_icon": "fas fa-circle-nodes"
},
"n_top_svgs": {
"type": "integer",
"default": 14,
Expand Down
1 change: 1 addition & 0 deletions subworkflows/local/downstream.nf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ workflow DOWNSTREAM {
.map { tuple(it[0], spatially_variable_genes_notebook) }
spatially_variable_genes_params = [
input_sdata: "sdata_processed.zarr",
svg_autocorr_method: params.svg_autocorr_method,
n_top_svgs: params.n_top_svgs,
artifact_dir: "artifacts",
output_csv: "spatially_variable_genes.csv",
Expand Down

0 comments on commit d898c8f

Please sign in to comment.