lilab-bcb / pegasus

A tool for analyzing trascriptomes of millions of single cells.

Home Page:https://pegasus.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: 'UnimodalDataView' object has no attribute '_clean_tmp'

Zifeng-L opened this issue · comments

When running the codes pg.write_output before pg.qc_metrics , the error existed as follows:
AttributeError Traceback (most recent call last)
in
----> 1 pg.write_output(data_sub, '/cluster/home/zfli/RProject/Lymphoma/TNHL/s8_garnett/ENA_annotated.h5ad')

~/anaconda2/envs/pegasus_env/lib/python3.8/site-packages/pegasusio/decorators.py in wrapper_timer(*args, **kwargs)
10 def wrapper_timer(*args, **kwargs):
11 start = time.perf_counter()
---> 12 result = func(*args, **kwargs)
13 end = time.perf_counter()
14 message = f"Function '{func.name}' finished in {{:.{precision}f}}s.".format(end - start)

~/anaconda2/envs/pegasus_env/lib/python3.8/site-packages/pegasusio/readwrite.py in write_output(data, output_file, file_type, is_sparse, precision)
226 if isinstance(data, UnimodalData):
227 data = MultimodalData(data)
--> 228 _tmp_multi = data._clean_tmp() # for each unidata, remove uns keys starting with '_tmp' and store these values to _tmp_multi
229
230 output_file = os.path.expanduser(os.path.expandvars(output_file))

AttributeError: 'UnimodalDataView' object has no attribute '_clean_tmp'

Can anyone help me?

Could you please tell me which version of pegasus and pegasusio that you are using?

commented

Hi @Zifeng1995 ,

It suggests that data_sub is a UnimodalDataView object instead of UnimodalData. This happens if you subset the original data. If you need to modify data_sub or write it to disk, you need to convert it back to UnimodalData by 'data_sub.copy()'.

Thus, if you try pg.write_output(data_sub.copy(), 'ENA_annotated.h5ad'), you should not receive any error message.

Hope it helps,
Bo

I have a question when working with multimodal data, for example, I have used three matrices containing the same cells to generate one multimodal data, as follows:

MultimodalData object with 3 UnimodalData: 'RNA-RNA', 'RNA-integrated', 'RNA-AN'
    It currently binds to UnimodalData object RNA-AN

When I filter the multimodaldata through barcode, I got a unimodaldata that only contains one matrix like this:

UnimodalData object with n_obs x n_vars = 120 x 2215
    UID: RNA-RNA; Genome: RNA; Modality: RNA
    It contains 1 matrix: 'counts'
    It currently binds to matrix 'counts' as X

I was wondering if there is a method to subset the entire multimodal data, allowing me to obtain multimodaldata with three matrices that only contain subset cells?

Additionally, I am not sure if you will update the pegasusIO related tutorials, as I feel the content is somewhat limited. For instance, processes like creating multimodal data from a matrix, such as CreateSeuratObject, took me a long time to figure out on my own.

Regardless, Pegasus is still a single-cell analysis tool that I really like. I have already used it into my own work and cited it, hoping it will continue to improve.