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

Fix _index and HGNC symbol indexing #7

Merged
merged 3 commits into from
Oct 10, 2024
Merged
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
15 changes: 13 additions & 2 deletions scdataloader/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
from scipy.sparse import issparse
from torch.utils.data import Dataset as torchDataset

from scdataloader.mapped import MappedCollection
from lamindb.core import MappedCollection
from lamindb.core._mapped_collection import _Connect
from scdataloader.utils import get_ancestry_mapping, load_genes
from lamindb.core.storage._anndata_accessor import _safer_read_index

from .config import LABELS_TOADD

Expand Down Expand Up @@ -107,7 +109,16 @@ def __post_init__(self):
self.genedf = load_genes(self.organisms)

self.genedf.columns = self.genedf.columns.astype(str)
self.mapped_dataset._check_aligned_vars(self.genedf.index.tolist())
self.check_aligned_vars()

def check_aligned_vars(self):
vars = self.genedf.index.tolist()
i = 0
for storage in self.mapped_dataset.storages:
with _Connect(storage) as store:
if len(set(_safer_read_index(store["var"]).tolist()) - set(vars)) == 0:
i += 1
print("{}% are aligned".format(i * 100 / len(self.mapped_dataset.storages)))

def __len__(self, **kwargs):
return self.mapped_dataset.__len__(**kwargs)
Expand Down
Loading