Skip to content

Commit

Permalink
Merge pull request #14 from klarman-cell-observatory/boli
Browse files Browse the repository at this point in the history
Multiple small changes.
  • Loading branch information
bli25 committed Jun 5, 2020
2 parents 2ea83cb + 2d77376 commit 6fe4487
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion pegasusio/hdf5_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ def _process_attrs(key_name: str, attrs: pd.DataFrame, attrs_multi: dict) -> Dic
layers["" if matkey == "X" else matkey] = data.get_matrix(matkey).T

file_attrs = {}
print(type(data.uns))
for key, value in data.uns.items():
if isinstance(value, str):
file_attrs[key] = value
Expand Down
2 changes: 1 addition & 1 deletion pegasusio/readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def read_input(
) -> MultimodalData:
"""Load data into memory.
This function is used to load input data into memory. Inputs can be in 10x genomics v2 & v3 formats (hdf5 or mtx), HCA DCP mtx and csv formats, Drop-seq dge format, and CSV format.
This function is used to load input data into memory. Inputs can be in 'zarr', 'h5ad', 'loom', '10x', 'mtx', 'csv', 'tsv' or 'fcs' (for flow/mass cytometry data) formats.
Parameters
----------
Expand Down
12 changes: 4 additions & 8 deletions pegasusio/text_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def load_one_mtx_file(path: str, file_name: str, genome: str, modality: str) ->
mat = csr_matrix((data, (row_ind, col_ind)), shape = shape)
mat.eliminate_zeros()

unidata = UnimodalData(barcode_metadata, feature_metadata, {"X": mat}, {"modality": modality, "genome": genome})
unidata = UnimodalData(barcode_metadata, feature_metadata, {"X": mat}, {"genome": genome, "modality": modality})
if format_type == "10x v3" or format_type == "10x v2":
unidata.separate_channels()

Expand All @@ -173,7 +173,7 @@ def _locate_mtx_file(path: str) -> str:
return file_names[0] if len(file_names) > 0 else None


def load_mtx_file(path: str, genome: str = None, modality: str = None, ngene: int = None) -> MultimodalData:
def load_mtx_file(path: str, genome: str = None, modality: str = None) -> MultimodalData:
"""Load gene-count matrix from Market Matrix files (10x v2, v3 and HCA DCP formats)
Parameters
Expand All @@ -185,8 +185,6 @@ def load_mtx_file(path: str, genome: str = None, modality: str = None, ngene: in
Genome name of the matrix. If None, genome will be inferred from path.
modality: `str`, optional (default: None)
Modality, choosing from 'rna', 'citeseq', 'hashing', 'tcr', 'bcr', 'crispr' or 'atac'. If None, use 'rna' as default.
ngene : `int`, optional (default: None)
Minimum number of genes to keep a barcode. Default is to keep all barcodes. Only apply to 'rna' modality
Returns
-------
Expand Down Expand Up @@ -218,13 +216,11 @@ def load_mtx_file(path: str, genome: str = None, modality: str = None, ngene: in
if genome is None:
genome = os.path.basename(path)
data.add_data(
genome,
load_one_mtx_file(
path,
file_name,
genome,
modality,
ngene=ngene,
modality
),
)
else:
Expand All @@ -233,7 +229,7 @@ def load_mtx_file(path: str, genome: str = None, modality: str = None, ngene: in
file_name = _locate_mtx_file(dir_entry.path)
if file_name is None:
raise ValueError(f"Folder {dir_entry.path} does not contain a mtx file!")
data.add_data(dir_entry.name, load_one_mtx_file(dir_entry.path, file_name, dir_entry.name, modality, ngene=ngene))
data.add_data(load_one_mtx_file(dir_entry.path, file_name, dir_entry.name, modality))

return data

Expand Down

0 comments on commit 6fe4487

Please sign in to comment.