Skip to content

Commit

Permalink
Merge pull request #53 from klarman-cell-observatory/yiming
Browse files Browse the repository at this point in the history
in a better format
  • Loading branch information
bli25 committed Jan 7, 2021
2 parents 7637a97 + d343027 commit dd08d79
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pegasusio/unimodal_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ def replace_none_df(value):

self.metadata = DataDict(metadata) # other metadata, a dictionary
if genome is not None:
self.metadata.__setitem__('genome', genome)
self.metadata['genome'] = genome
if modality is not None:
self.metadata.__setitem__('modality', modality)
self.metadata['modality'] = modality

if cur_matrix not in matrices.keys():
raise ValueError("Cannot find the default count matrix to bind to. Please set 'cur_matrix' argument in UnimodalData constructor!")
self._cur_matrix = cur_matrix # cur_matrix

if len(self.barcode_metadata) > 0:
Expand Down Expand Up @@ -90,7 +92,8 @@ def replace_none_df(value):
def __repr__(self) -> str:
repr_str = f"{self.__class__.__name__} object with n_obs x n_vars = {self.barcode_metadata.shape[0]} x {self.feature_metadata.shape[0]}"
repr_str += f"\n Genome: {self.get_genome()}; Modality: {self.get_modality()}"
repr_str += f"\n It contains {len(self.matrices)} matrices: {str(list(self.matrices))[1:-1]}"
mat_word = 'matrices' if len(self.matrices) > 1 else 'matrix'
repr_str += f"\n It contains {len(self.matrices)} {mat_word}: {str(list(self.matrices))[1:-1]}"
repr_str += f"\n It currently binds to matrix '{self._cur_matrix}' as X\n" if len(self.matrices) > 0 else "\n It currently binds to no matrix\n"
for key in ["obs", "var", "obsm", "varm", "uns"]:
repr_str += f"\n {key}: {str(list(getattr(self, key).keys()))[1:-1]}"
Expand Down

0 comments on commit dd08d79

Please sign in to comment.