diff --git a/README.md b/README.md index 16c196d..76ad5a9 100644 --- a/README.md +++ b/README.md @@ -260,8 +260,9 @@ with read_h5ad(file_path, edit=True) as cap_adata: sparse_dataset = cap_adata.layers["empty_sparse_matrix"] sparse_dataset.append(chunk_data) # chunk_data must be 'csr' or 'csc' matrix -# Remove layer -cap_adata.remove_layer("dense_array") +with read_h5ad(file_path, edit=True) as cap_adata: + # Remove layer + cap_adata.remove_layer("dense_array") ``` #### 8. Join and Merge DataFrames diff --git a/cap_anndata/cap_anndata.py b/cap_anndata/cap_anndata.py index 57a74be..75b8b0c 100644 --- a/cap_anndata/cap_anndata.py +++ b/cap_anndata/cap_anndata.py @@ -255,6 +255,10 @@ def raw(self) -> RawLayer: logger.warning("Can't read raw.var since raw layer doesn't exist!") return + if len(self._file["raw"].keys()) == 0: + logger.warning("The raw layer is empty!") + return + self._raw = RawLayer(self._file) return self._raw