Skip to content

Commit

Permalink
v1.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinblampey committed Apr 8, 2024
1 parent 12c673f commit 02f2109
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [1.0.10] - tbd
## [1.0.10] - 2024-04-08

### Added
- CosMX reader with image stitching (experimental)
Expand All @@ -8,6 +8,7 @@
- Minimum number of transcripts per patch set to 4000 (#41)
- Config files refactoring (configs added or renamed)
- Readers refactoring
- Section with error during report are not displayed (instead of throwing an error)

## [1.0.9] - 2024-04-03

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sopa"
version = "1.0.9"
version = "1.0.10"
description = "Spatial-omics pipeline and analysis"
documentation = "https://gustaveroussy.github.io/sopa"
homepage = "https://gustaveroussy.github.io/sopa"
Expand Down
35 changes: 18 additions & 17 deletions sopa/io/report/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def _kdeplot_vmax_quantile(values: np.ndarray, quantile: float = 0.95):


class SectionBuilder:
SECTION_NAMES = [
"general_section",
"cell_section",
"channel_section",
"transcripts_section",
"representation_section",
]

def __init__(self, sdata: SpatialData):
self.sdata = sdata
self.adata = self.sdata.tables.get(SopaKeys.TABLE)
Expand All @@ -64,8 +72,6 @@ def _table_has(self, key, default=False):
return self.adata.uns[SopaKeys.UNS_KEY].get(key, default)

def general_section(self):
log.info("Writing general section")

return Section(
"General",
[
Expand All @@ -82,8 +88,6 @@ def general_section(self):
)

def cell_section(self):
log.info("Writing cell section")

shapes_key, _ = get_boundaries(self.sdata, return_key=True)
coord_system = get_intrinsic_cs(self.sdata, shapes_key)

Expand Down Expand Up @@ -111,8 +115,6 @@ def cell_section(self):
)

def channel_section(self):
log.info("Writing channel section")

image = get_spatial_image(self.sdata)

subsections = [
Expand Down Expand Up @@ -154,8 +156,6 @@ def transcripts_section(self):
if not self._table_has(SopaKeys.UNS_HAS_TRANSCRIPTS):
return None

log.info("Writing transcript section")

mean_transcript_count = self.adata.X.mean(0).A1
low_average = mean_transcript_count < LOW_AVERAGE_COUNT

Expand Down Expand Up @@ -183,8 +183,6 @@ def transcripts_section(self):
return Section("Transcripts", [SubSection("Quality controls", QC_subsubsections)])

def representation_section(self, max_obs: int = 400_000):
log.info("Writing representation section")

if self._table_has(SopaKeys.UNS_HAS_TRANSCRIPTS):
sc.pp.normalize_total(self.adata)
sc.pp.log1p(self.adata)
Expand All @@ -209,11 +207,14 @@ def representation_section(self, max_obs: int = 400_000):
)

def compute_sections(self) -> list[Section]:
sections = [
self.general_section(),
self.cell_section(),
self.channel_section(),
self.transcripts_section(),
self.representation_section(),
]
sections = []

for name in self.SECTION_NAMES:
try:
log.info(f"Writing {name}")
section = getattr(self, name)()
sections.append(section)
except Exception as e:
log.warn(f"Section {name} failed with error {e}")

return [section for section in sections if section is not None]
2 changes: 1 addition & 1 deletion sopa/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def uniform(
*_,
length: int = 2_048,
cell_density: float = 1e-4,
n_points_per_cell: int = 50,
n_points_per_cell: int = 100,
c_coords: list[str] = ["DAPI", "CK", "CD3", "CD20"],
genes: int | list[str] = ["EPCAM", "CD3E", "CD20", "CXCL4", "CXCL10"],
sigma_factor: float = 0.05,
Expand Down

0 comments on commit 02f2109

Please sign in to comment.