Skip to content

Commit

Permalink
Merge pull request #46 from klarman-cell-observatory/yiming
Browse files Browse the repository at this point in the history
Adjust load_loom_file to work with Seurat-style
  • Loading branch information
yihming committed Dec 4, 2020
2 parents 51559be + 0e725b7 commit aee26a1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pegasusio/hdf5_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def load_10x_h5_file_v2(h5_in: h5py.Group) -> MultimodalData:
ids = group["genes"][...].astype(str)
names = group["gene_names"][...].astype(str)

unidata = UnimodalData({"barcodekey": barcodes},
unidata = UnimodalData({"barcodekey": barcodes},
{"featurekey": names, "featureid": ids},
{"X": mat},
{"modality": "rna", "genome": genome}
Expand Down Expand Up @@ -171,8 +171,11 @@ def load_loom_file(input_loom: str, genome: str = None, modality: str = None) ->
--------
>>> io.load_loom_file('example.loom', genome = 'GRCh38')
"""
col_trans = {"CellID": "barcodekey", "obs_names": "barcodekey"}
row_trans = {"Gene": "featurekey", "var_names": "featurekey", "Accession": "featureid", "gene_ids": "featureid"}
col_trans = {"CellID": "barcodekey", "obs_names": "barcodekey", "cell_names": "barcodekey"}
row_trans = {
"Gene": "featurekey", "var_names": "featurekey", "gene_names": "featurekey",
"Accession": "featureid", "gene_ids": "featureid", "ensembl_ids": "featureid",
}

import loompy
with loompy.connect(input_loom) as ds:
Expand Down Expand Up @@ -216,8 +219,9 @@ def load_loom_file(input_loom: str, genome: str = None, modality: str = None) ->
metadata["modality"] = metadata.pop("experiment_type")
else:
metadata["modality"] = "rna"

unidata = UnimodalData(barcode_metadata, feature_metadata, matrices, metadata, barcode_multiarrays, feature_multiarrays)
unidata.separate_channels()

data = MultimodalData(unidata)
return data
Expand Down

0 comments on commit aee26a1

Please sign in to comment.