scdataloader 1.9.2__py3-none-any.whl → 2.0.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.
scdataloader/utils.py CHANGED
@@ -18,45 +18,42 @@ from scipy.stats import median_abs_deviation
18
18
  from torch import Tensor
19
19
 
20
20
 
21
- def slurm_restart_count(use_mine: bool = False):
22
- if use_mine:
23
- return int(os.getenv("MY_SLURM_RESTART_COUNT", 0))
24
- else:
25
- return int(os.getenv("SLURM_RESTART_COUNT", 0))
21
+ def fileToList(filename: str, strconv: callable = lambda x: x) -> list:
22
+ """
23
+ loads an input file with a\\n b\\n.. into a list [a,b,..]
26
24
 
25
+ Args:
26
+ input_str (str): The input string to be completed.
27
27
 
28
- def downsample_profile(mat: Tensor, dropout: float):
28
+ Returns:
29
+ str: The completed string with 'complete' appended.
29
30
  """
30
- This function downsamples the expression profile of a given single cell RNA matrix.
31
-
32
- The noise is applied based on the renoise parameter,
33
- the total counts of the matrix, and the number of genes. The function first calculates the noise
34
- threshold (scaler) based on the renoise parameter. It then generates an initial matrix count by
35
- applying a Poisson distribution to a random tensor scaled by the total counts and the number of genes.
36
- The function then models the sampling zeros by applying a Poisson distribution to a random tensor
37
- scaled by the noise threshold, the total counts, and the number of genes. The function also models
38
- the technical zeros by generating a random tensor and comparing it to the noise threshold. The final
39
- matrix count is calculated by subtracting the sampling zeros from the initial matrix count and
40
- multiplying by the technical zeros. The function ensures that the final matrix count is not less
41
- than zero by taking the maximum of the final matrix count and a tensor of zeros. The function
42
- returns the final matrix count.
31
+ with open(filename) as f:
32
+ return [strconv(val[:-1]) for val in f.readlines()]
33
+
34
+
35
+ def listToFile(li: list, filename: str, strconv: callable = lambda x: str(x)) -> None:
36
+ """
37
+ listToFile loads a list with [a,b,..] into an input file a\\n b\\n..
43
38
 
44
39
  Args:
45
- mat (torch.Tensor): The input matrix.
46
- dropout (float): The renoise parameter.
40
+ l (list): The list of elements to be written to the file.
41
+ filename (str): The name of the file where the list will be written.
42
+ strconv (callable, optional): A function to convert each element of the list to a string. Defaults to str.
47
43
 
48
44
  Returns:
49
- torch.Tensor: The matrix count after applying noise.
45
+ None
50
46
  """
51
- batch = mat.shape[0]
52
- ngenes = mat.shape[1]
53
- dropout = dropout * 1.1
54
- # we model the sampling zeros (dropping 30% of the reads)
55
- res = torch.poisson((mat * (dropout / 2))).int()
56
- # we model the technical zeros (dropping 50% of the genes)
57
- notdrop = (torch.rand((batch, ngenes), device=mat.device) >= (dropout / 2)).int()
58
- mat = (mat - res) * notdrop
59
- return torch.maximum(mat, torch.zeros((1, 1), device=mat.device, dtype=torch.int))
47
+ with open(filename, "w") as f:
48
+ for item in li:
49
+ f.write("%s\n" % strconv(item))
50
+
51
+
52
+ def slurm_restart_count(use_mine: bool = False):
53
+ if use_mine:
54
+ return int(os.getenv("MY_SLURM_RESTART_COUNT", 0))
55
+ else:
56
+ return int(os.getenv("SLURM_RESTART_COUNT", 0))
60
57
 
61
58
 
62
59
  def createFoldersFor(filepath: str):
@@ -248,7 +245,10 @@ def validate(adata: AnnData, organism: str, need_all=False):
248
245
  if not bt.Gene.validate(
249
246
  adata.var.index, field="ensembl_gene_id", organism=organism
250
247
  ).all():
251
- raise ValueError("Invalid gene ensembl id found")
248
+ if not bt.Gene.validate(
249
+ adata.var.index, field="stable_id", organism=organism
250
+ ).all():
251
+ raise ValueError("Invalid gene ensembl id found")
252
252
  return True
253
253
 
254
254
 
@@ -293,7 +293,7 @@ def get_ancestry_mapping(all_elem: list, onto_df: pd.DataFrame):
293
293
  for val in ancestors.values():
294
294
  full_ancestors |= set(val)
295
295
  # removing ancestors that are not in our datasets
296
- full_ancestors = full_ancestors & set(ancestors.keys())
296
+ # full_ancestors = full_ancestors & set(ancestors.keys())
297
297
  leafs = set(all_elem) - full_ancestors
298
298
  full_ancestors = full_ancestors - leafs
299
299
 
@@ -387,6 +387,9 @@ def load_genes(organisms: Union[str, list] = "NCBITaxon:9606"): # "NCBITaxon:10
387
387
  genesdf = bt.Gene.filter(
388
388
  organism_id=bt.Organism.filter(ontology_id=organism).first().id
389
389
  ).df()
390
+ genesdf.loc[genesdf.ensembl_gene_id.isna(), "ensembl_gene_id"] = genesdf.loc[
391
+ genesdf.ensembl_gene_id.isna(), "stable_id"
392
+ ]
390
393
  genesdf = genesdf.drop_duplicates(subset="ensembl_gene_id")
391
394
  genesdf = genesdf.set_index("ensembl_gene_id").sort_index()
392
395
  # mitochondrial genes
@@ -408,6 +411,9 @@ def load_genes(organisms: Union[str, list] = "NCBITaxon:9606"): # "NCBITaxon:10
408
411
  "_aux",
409
412
  "_branch_code",
410
413
  "space_id",
414
+ "ncbi_gene_ids",
415
+ "synonyms",
416
+ "description",
411
417
  ]:
412
418
  if col in organismdf.columns:
413
419
  organismdf.drop(columns=[col], inplace=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scdataloader
3
- Version: 1.9.2
3
+ Version: 2.0.0
4
4
  Summary: a dataloader for single cell data in lamindb
5
5
  Project-URL: repository, https://github.com/jkobject/scDataLoader
6
6
  Author-email: jkobject <jkobject@gmail.com>
@@ -12,14 +12,13 @@ Requires-Dist: anndata>=0.9.0
12
12
  Requires-Dist: biomart>=0.9.0
13
13
  Requires-Dist: cellxgene-census>=0.1.0
14
14
  Requires-Dist: django>=4.0.0
15
- Requires-Dist: harmonypy>=0.0.10
16
15
  Requires-Dist: ipykernel>=6.20.0
17
16
  Requires-Dist: jupytext>=1.16.0
18
- Requires-Dist: lamindb[bionty,cellregistry,jupyter,zarr]<2,>=1.0.4
17
+ Requires-Dist: lamindb[bionty,cellregistry,jupyter,zarr]==1.0.4
19
18
  Requires-Dist: leidenalg>=0.8.0
19
+ Requires-Dist: lightning>=2.3.0
20
20
  Requires-Dist: matplotlib>=3.5.0
21
21
  Requires-Dist: numpy==1.26.0
22
- Requires-Dist: palantir>=1.3.3
23
22
  Requires-Dist: pandas>=2.0.0
24
23
  Requires-Dist: pytorch-lightning>=2.3.0
25
24
  Requires-Dist: scikit-misc>=0.5.0
@@ -0,0 +1,16 @@
1
+ scdataloader/__init__.py,sha256=Z5HURehoWw1GrecImmTXIkv4ih8Q5RxNQWPm8zjjXOA,226
2
+ scdataloader/__main__.py,sha256=3aZnqYrH8XDT9nW9Dbb3o9kr-sx1STmXDQHxBo_h_q0,8719
3
+ scdataloader/base.py,sha256=M1gD59OffRdLOgS1vHKygOomUoAMuzjpRtAfM3SBKF8,338
4
+ scdataloader/collator.py,sha256=pC5PVvxwyE7e84cdr5YC4ae85NbJubk6bfldIfOLFNE,12039
5
+ scdataloader/config.py,sha256=nM8J11z2-lornryy1KxDE9675Rcxge4RGhdmpeiMhuI,7173
6
+ scdataloader/data.json,sha256=Zb8c27yk3rwMgtAU8kkiWWAyUwYBrlCqKUyEtaAx9i8,8785
7
+ scdataloader/data.py,sha256=skUBLX07cxC9gl4X0zDQ3rUpm0EJoUjngvdhL4lo5IA,18633
8
+ scdataloader/datamodule.py,sha256=fKYjQlli9wm3uCJbD6FedooNSorjl5vfg5LuwDCQkQU,34388
9
+ scdataloader/mapped.py,sha256=0erd1vCfCnUkdMuFO4Md0d78gNeNaHSWwRVXN4zhtQQ,29802
10
+ scdataloader/preprocess.py,sha256=CA0pvfcfZ_nMhso7vl9MfKhKfaJbYwANqHfsa5Vyco4,38425
11
+ scdataloader/utils.py,sha256=YzTCV1IkfXIaQmtdTXJvo_Vj1l_Dhau7UUM_BBccvL0,27939
12
+ scdataloader-2.0.0.dist-info/METADATA,sha256=rNBXB06aOnCNTu8LjijBTReTototB2tRnGmnHaFtyVE,10328
13
+ scdataloader-2.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ scdataloader-2.0.0.dist-info/entry_points.txt,sha256=VXAN1m_CjbdLJ6SKYR0sBLGDV4wvv31ri7fWWuwbpno,60
15
+ scdataloader-2.0.0.dist-info/licenses/LICENSE,sha256=rGy_eYmnxtbOvKs7qt5V0czSWxJwgX_MlgMyTZwDHbc,1073
16
+ scdataloader-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jérémie Kalfon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
scdataloader/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.9.2
@@ -1,16 +0,0 @@
1
- scdataloader/VERSION,sha256=u1mRkBjudkgsI_HORCGc5MnGOTxl7w3a5A0y151BO7U,6
2
- scdataloader/__init__.py,sha256=Z5HURehoWw1GrecImmTXIkv4ih8Q5RxNQWPm8zjjXOA,226
3
- scdataloader/__main__.py,sha256=3aZnqYrH8XDT9nW9Dbb3o9kr-sx1STmXDQHxBo_h_q0,8719
4
- scdataloader/base.py,sha256=M1gD59OffRdLOgS1vHKygOomUoAMuzjpRtAfM3SBKF8,338
5
- scdataloader/collator.py,sha256=qb1SDQ358R4w56cxOXvVLpodlZpGfVDCXocFIhqpJ0I,12867
6
- scdataloader/config.py,sha256=YQUKCyYTg4wTseBWumPDHKtmqI7DMR-zu5FPJUWkG-c,6549
7
- scdataloader/data.py,sha256=xWlNU6cJmrzP4BFMsJDIksLaxe1pUfgDBlQ_IeLIXj0,15578
8
- scdataloader/datamodule.py,sha256=MaBSH0MqZdDbwiGnCM4xjz0KF05WT00sycJStS7GL5w,19786
9
- scdataloader/mapped.py,sha256=qzhGYQ2S3IDXnnO1EM1wO_png5lDiOtfuDeYc1pQaXg,27303
10
- scdataloader/preprocess.py,sha256=LNXlP80rj8Ze2ElyIgLuF9x_lNA78jAI-seGMOyMKGs,37496
11
- scdataloader/utils.py,sha256=7ycZoV01Gn3WDHOTmXqxMXlzBPSfYtjc9NbGI7gjdwI,28445
12
- scdataloader-1.9.2.dist-info/METADATA,sha256=jLx2v-SJTAv-jsUjmgLNIrTenwtnfUHTnKYuy9hI3lg,10363
13
- scdataloader-1.9.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- scdataloader-1.9.2.dist-info/entry_points.txt,sha256=VXAN1m_CjbdLJ6SKYR0sBLGDV4wvv31ri7fWWuwbpno,60
15
- scdataloader-1.9.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
16
- scdataloader-1.9.2.dist-info/RECORD,,