lamindb 1.2.0__py3-none-any.whl → 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lamindb/__init__.py CHANGED
@@ -72,7 +72,7 @@ Backward compatibility.
72
72
 
73
73
  # ruff: noqa: I001
74
74
  # denote a release candidate for 0.1.0 with 0.1rc1, 0.1a1, 0.1b1, etc.
75
- __version__ = "1.2.0"
75
+ __version__ = "1.3.0"
76
76
 
77
77
  import warnings
78
78
 
lamindb/core/_context.py CHANGED
@@ -301,6 +301,12 @@ class Context:
301
301
  """
302
302
  from lamindb.models import Project
303
303
 
304
+ instance_settings = ln_setup.settings.instance
305
+ # similar logic here: https://github.com/laminlabs/lamindb/pull/2527
306
+ # TODO: refactor upon new access management
307
+ if instance_settings.dialect == "postgresql" and "read" in instance_settings.db:
308
+ logger.warning("skipping track(), connected in read-only mode")
309
+ return None
304
310
  if project is not None:
305
311
  project_record = Project.filter(
306
312
  Q(name=project) | Q(uid=project)
@@ -83,6 +83,7 @@ from ._core import (
83
83
  mudata_papalexi21_subset,
84
84
  schmidt22_crispra_gws_IFNG,
85
85
  schmidt22_perturbseq,
86
+ spatialdata_blobs,
86
87
  )
87
88
  from ._fake import fake_bio_notebook_titles
88
89
  from ._small import (
@@ -13,6 +13,7 @@ from lamindb.core._settings import settings
13
13
 
14
14
  if TYPE_CHECKING:
15
15
  from mudata import MuData
16
+ from spatialdata import SpatialData
16
17
 
17
18
 
18
19
  def file_fcs() -> Path:
@@ -552,3 +553,25 @@ def schmidt22_perturbseq(basedir=".") -> Path: # pragma: no cover
552
553
  "schmidt22_perturbseq.h5ad",
553
554
  )
554
555
  return Path(filepath).rename(Path(basedir) / filepath)
556
+
557
+
558
+ def spatialdata_blobs() -> SpatialData:
559
+ """Example SpatialData dataset for tutorials."""
560
+ from spatialdata.datasets import blobs
561
+
562
+ sdata = blobs()
563
+ sdata.attrs["sample"] = {
564
+ "assay": "Visium Spatial Gene Expression",
565
+ "disease": "Alzheimer disease",
566
+ "developmental_stage": "adult stage",
567
+ }
568
+ sdata.tables["table"].var.index = [
569
+ "ENSG00000139618", # BRCA2
570
+ "ENSG00000157764", # BRAF
571
+ "ENSG00000999999", # Does not exist
572
+ ]
573
+ sdata.tables["table"].obs["sample_region"] = pd.Categorical(
574
+ ["sample region 1"] * 13 + ["sample region 2"] * 13
575
+ )
576
+
577
+ return sdata
@@ -8,9 +8,11 @@ import pandas as pd
8
8
 
9
9
 
10
10
  def small_dataset1(
11
- otype: Literal["DataFrame", "AnnData"],
11
+ otype: Literal["DataFrame", "AnnData"] = "DataFrame",
12
12
  gene_symbols_in_index: bool = False,
13
13
  with_typo: bool = False,
14
+ with_cell_type_synonym: bool = False,
15
+ with_cell_type_typo: bool = False,
14
16
  ) -> pd.DataFrame | ad.AnnData:
15
17
  # define the data in the dataset
16
18
  # it's a mix of numerical measurements and observation-level metadata
@@ -19,14 +21,25 @@ def small_dataset1(
19
21
  var_ids = ["CD8A", "CD4", "CD14"]
20
22
  else:
21
23
  var_ids = ["ENSG00000153563", "ENSG00000010610", "ENSG00000170458"]
24
+ abt_cell = (
25
+ "CD8-pos alpha-beta T cell"
26
+ if with_cell_type_typo
27
+ else "CD8-positive, alpha-beta T cell"
28
+ )
22
29
  dataset_dict = {
23
30
  var_ids[0]: [1, 2, 3],
24
31
  var_ids[1]: [3, 4, 5],
25
32
  var_ids[2]: [5, 6, 7],
26
33
  "perturbation": pd.Categorical(["DMSO", ifng, "DMSO"]),
27
34
  "sample_note": ["was ok", "looks naah", "pretty! 🤩"],
28
- "cell_type_by_expert": pd.Categorical(["B cell", "T cell", "T cell"]),
35
+ "cell_type_by_expert": pd.Categorical(
36
+ ["B-cell" if with_cell_type_synonym else "B cell", abt_cell, abt_cell]
37
+ ),
29
38
  "cell_type_by_model": pd.Categorical(["B cell", "T cell", "T cell"]),
39
+ "assay_oid": pd.Categorical(["EFO:0008913", "EFO:0008913", "EFO:0008913"]),
40
+ "concentration": ["0.1%", "200 nM", "0.1%"],
41
+ "treatment_time_h": [24, 24, 6],
42
+ "donor": ["D0001", "D0002", None],
30
43
  }
31
44
  # define the dataset-level metadata
32
45
  metadata = {
@@ -100,6 +113,7 @@ def small_dataset3_cellxgene(
100
113
  "disease_ontology_term_id": ["MONDO:0004975", "MONDO:0004980", "MONDO:0004980"],
101
114
  "organism": ["human", "human", "human"],
102
115
  "sex": ["female", "male", "unknown"],
116
+ "sex_ontology_term_id": ["PATO:0000383", "PATO:0000384", "unknown"],
103
117
  "tissue": ["lungg", "lungg", "heart"],
104
118
  "donor": ["-1", "1", "2"],
105
119
  }
@@ -45,8 +45,7 @@ def infer_suffix(dmem: SupportedDataTypes, format: str | None = None):
45
45
  dmem,
46
46
  "SpatialData",
47
47
  "spatialdata",
48
- lambda obj: "."
49
- + (
48
+ lambda obj: (
50
49
  format
51
50
  if format is not None and format in {"spatialdata.zarr", "zarr"}
52
51
  else ".zarr"