Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
rev: v0.8.6
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
pp.compute_extracellular_counts
pp.define_extracellular
pp.compute_crosstab
pp.format_adata
pp.format_adata
```

## Tools
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
"anndata": ("https://anndata.readthedocs.io/en/stable/", None),
"scanpy": ("https://scanpy.readthedocs.io/en/stable/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
"spatialdata": ("https://spatialdata.scverse.org/en/stable/",None)
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
"spatialdata": ("https://spatialdata.scverse.org/en/stable/", None),
}

# List of patterns, relative to source directory, that match files and
Expand Down Expand Up @@ -129,5 +129,5 @@
nitpick_ignore = [
# If building the documentation fails because of a missing link that is outside your control,
# you can add an exception to this list.
("py:class", "igraph.Graph"),
("py:class", "igraph.Graph"),
]
17 changes: 8 additions & 9 deletions docs/notebooks/0_format_Xenium_sdata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
}
],
"source": [
"path='/media/sergio/Discovair_final/Xenium_Prime_Mouse_Brain_Coronal_FF_outs'\n",
"sdata=spatialdata_io.xenium(path)"
"path = \"/media/sergio/Discovair_final/Xenium_Prime_Mouse_Brain_Coronal_FF_outs\"\n",
"sdata = spatialdata_io.xenium(path)"
]
},
{
Expand All @@ -66,7 +66,7 @@
}
],
"source": [
"outpath='/media/sergio/Discovair_final/mousebrain_prime.zarr'\n",
"outpath = \"/media/sergio/Discovair_final/mousebrain_prime.zarr\"\n",
"sdata.write(outpath)"
]
},
Expand Down Expand Up @@ -130,7 +130,7 @@
}
],
"source": [
"xenium_path='/media/sergio/Discovair_final/mousebrain_prime.zarr'\n",
"xenium_path = \"/media/sergio/Discovair_final/mousebrain_prime.zarr\"\n",
"sdata = sd.read_zarr(xenium_path)\n",
"sdata"
]
Expand Down Expand Up @@ -179,7 +179,7 @@
" axes=[\"x\", \"y\"],\n",
" min_coordinate=[17500, 0],\n",
" max_coordinate=[35000, 15000],\n",
" target_coordinate_system='global',\n",
" target_coordinate_system=\"global\",\n",
")\n",
"\n",
"cropped_sdata"
Expand Down Expand Up @@ -209,8 +209,7 @@
}
],
"source": [
"import spatialdata_plot\n",
"cropped_sdata.pl.render_images(\"morphology_focus\").pl.show( title=\"Morphology image\")"
"cropped_sdata.pl.render_images(\"morphology_focus\").pl.show(title=\"Morphology image\")"
]
},
{
Expand All @@ -232,8 +231,8 @@
}
],
"source": [
"xenium_path_cropped='/media/sergio/Discovair_final/mousebrain_prime_half.zarr'\n",
"cropped_sdata.write(xenium_path_cropped,overwrite=True)"
"xenium_path_cropped = \"/media/sergio/Discovair_final/mousebrain_prime_half.zarr\"\n",
"cropped_sdata.write(xenium_path_cropped, overwrite=True)"
]
}
],
Expand Down
21 changes: 10 additions & 11 deletions notebooks/spatialdata_tutorials/0_format_Xenium_sdata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"metadata": {},
"outputs": [],
"source": [
"import spatialdata_io\n",
"import spatialdata as sd"
"import spatialdata as sd\n",
"import spatialdata_io"
]
},
{
Expand All @@ -39,8 +39,8 @@
}
],
"source": [
"path='/media/sergio/Discovair_final/Xenium_Prime_Mouse_Brain_Coronal_FF_outs'\n",
"sdata=spatialdata_io.xenium(path)"
"path = \"/media/sergio/Discovair_final/Xenium_Prime_Mouse_Brain_Coronal_FF_outs\"\n",
"sdata = spatialdata_io.xenium(path)"
]
},
{
Expand All @@ -66,7 +66,7 @@
}
],
"source": [
"outpath='/media/sergio/Discovair_final/mousebrain_prime.zarr'\n",
"outpath = \"/media/sergio/Discovair_final/mousebrain_prime.zarr\"\n",
"sdata.write(outpath)"
]
},
Expand Down Expand Up @@ -130,7 +130,7 @@
}
],
"source": [
"xenium_path='/media/sergio/Discovair_final/mousebrain_prime.zarr'\n",
"xenium_path = \"/media/sergio/Discovair_final/mousebrain_prime.zarr\"\n",
"sdata = sd.read_zarr(xenium_path)\n",
"sdata"
]
Expand Down Expand Up @@ -179,7 +179,7 @@
" axes=[\"x\", \"y\"],\n",
" min_coordinate=[17500, 0],\n",
" max_coordinate=[35000, 15000],\n",
" target_coordinate_system='global',\n",
" target_coordinate_system=\"global\",\n",
")\n",
"\n",
"cropped_sdata"
Expand Down Expand Up @@ -209,8 +209,7 @@
}
],
"source": [
"import spatialdata_plot\n",
"cropped_sdata.pl.render_images(\"morphology_focus\").pl.show( title=\"Morphology image\")"
"cropped_sdata.pl.render_images(\"morphology_focus\").pl.show(title=\"Morphology image\")"
]
},
{
Expand All @@ -232,8 +231,8 @@
}
],
"source": [
"xenium_path_cropped='/media/sergio/Discovair_final/mousebrain_prime_half.zarr'\n",
"cropped_sdata.write(xenium_path_cropped,overwrite=True)"
"xenium_path_cropped = \"/media/sergio/Discovair_final/mousebrain_prime_half.zarr\"\n",
"cropped_sdata.write(xenium_path_cropped, overwrite=True)"
]
}
],
Expand Down
67 changes: 45 additions & 22 deletions notebooks/spatialdata_tutorials/1_run_segmentation_free.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
"metadata": {},
"outputs": [],
"source": [
"import spatialdata_io\n",
"import spatialdata as sd\n",
"import pandas as pd\n",
"import spatialdata_plot\n",
"import sys\n",
"\n",
"import spatialdata as sd\n",
"\n",
"sys.path.append(\"../../src\")\n",
"import troutpy "
"import troutpy"
]
},
{
Expand Down Expand Up @@ -40,8 +39,8 @@
}
],
"source": [
"xenium_path_cropped='/media/sergio/Discovair_final/mousebrain_prime_crop.zarr'\n",
"sdata= sd.read_zarr(xenium_path_cropped)"
"xenium_path_cropped = \"/media/sergio/Discovair_final/mousebrain_prime_crop.zarr\"\n",
"sdata = sd.read_zarr(xenium_path_cropped)"
]
},
{
Expand Down Expand Up @@ -81,11 +80,12 @@
}
],
"source": [
"#define points2regions_params\n",
"points2regions_params={'num_clusters':100, 'pixel_width':0.4, 'pixel_smoothing':3.5}\n",
"#run_segmentation_free\n",
"troutpy.tl.segmentation_free_clustering(sdata, params=points2regions_params, \n",
" x='x', y='y', feature_name='feature_name', transcript_id='transcript_id')"
"# define points2regions_params\n",
"points2regions_params = {\"num_clusters\": 100, \"pixel_width\": 0.4, \"pixel_smoothing\": 3.5}\n",
"# run_segmentation_free\n",
"troutpy.tl.segmentation_free_clustering(\n",
" sdata, params=points2regions_params, x=\"x\", y=\"y\", feature_name=\"feature_name\", transcript_id=\"transcript_id\"\n",
")"
]
},
{
Expand All @@ -110,7 +110,7 @@
}
],
"source": [
"troutpy.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 All @@ -130,7 +130,7 @@
}
],
"source": [
"len(sdata.points['transcripts']['extracellular'].compute())"
"len(sdata.points[\"transcripts\"][\"extracellular\"].compute())"
]
},
{
Expand All @@ -151,7 +151,8 @@
],
"source": [
"import numpy as np\n",
"np.sum(sdata.points['transcripts']['extracellular'].compute())"
"\n",
"np.sum(sdata.points[\"transcripts\"][\"extracellular\"].compute())"
]
},
{
Expand All @@ -173,8 +174,8 @@
}
],
"source": [
"xenium_path_cropped='/media/sergio/Discovair_final/mousebrain_prime_crop_points2regions.zarr'\n",
"sdata.write(xenium_path_cropped,overwrite=True)"
"xenium_path_cropped = \"/media/sergio/Discovair_final/mousebrain_prime_crop_points2regions.zarr\"\n",
"sdata.write(xenium_path_cropped, overwrite=True)"
]
},
{
Expand All @@ -184,13 +185,35 @@
"outputs": [],
"source": [
"### work a bit into better functions for plotting here\n",
"plot_data=sdata.points['transcripts'][['segmentation_free_clusters','overlaps_cell','overlaps_nucleus']].compute()\n",
"troutpy.pl.plot_crosstab(plot_data,xvar='segmentation_free_clusters',yvar='overlaps_cell',normalize=True,axis=1,kind='bar',figsize=(20,7),stacked=True,cmap='coolwarm',sortby=True)\n",
"troutpy.pl.plot_crosstab(plot_data,xvar='segmentation_free_clusters',yvar='overlaps_nucleus',normalize=True,axis=1,kind='bar',figsize=(20,7),stacked=True,cmap='coolwarm',sortby=1)\n",
"plot_data = sdata.points[\"transcripts\"][[\"segmentation_free_clusters\", \"overlaps_cell\", \"overlaps_nucleus\"]].compute()\n",
"troutpy.pl.plot_crosstab(\n",
" plot_data,\n",
" xvar=\"segmentation_free_clusters\",\n",
" yvar=\"overlaps_cell\",\n",
" normalize=True,\n",
" axis=1,\n",
" kind=\"bar\",\n",
" figsize=(20, 7),\n",
" stacked=True,\n",
" cmap=\"coolwarm\",\n",
" sortby=True,\n",
")\n",
"troutpy.pl.plot_crosstab(\n",
" plot_data,\n",
" xvar=\"segmentation_free_clusters\",\n",
" yvar=\"overlaps_nucleus\",\n",
" normalize=True,\n",
" axis=1,\n",
" kind=\"bar\",\n",
" figsize=(20, 7),\n",
" stacked=True,\n",
" cmap=\"coolwarm\",\n",
" sortby=1,\n",
")\n",
"\n",
"\n",
"input_data=sdata.points['transcripts'][['missegmentation_associated']].compute()\n",
"troutpy.pl.pie_of_positive(input_data,groupby='missegmentation_associated',save=True)"
"input_data = sdata.points[\"transcripts\"][[\"missegmentation_associated\"]].compute()\n",
"troutpy.pl.pie_of_positive(input_data, groupby=\"missegmentation_associated\", save=True)"
]
}
],
Expand Down
Loading
Loading