Closed inenj closed 2 months ago
Hi,
So the issue is you are trying to use SCE commands (assay
and colData
) on Seurat object. You don't need to run:
seurat_object <- CreateSeuratObject(counts = assay(rse, "counts"), meta.data = as.data.frame(colData(rse)))
You can just read the rds file and then if you want SCE just run the as. SingleCellExperiment
line that you have.
Best, Sam
Hi,
Thank you so much for helping me out. I'm still getting an error. I'm guessing it's because it doesn't contain the necessary annotation information I need to create a custom annotation reference. Thank you anyways.
I am following a tutorial online to create a custom reference dataset to annotate cells using downloaded data from this publication: https://www.nature.com/articles/s42003-020-0922-4
I downloaded the data from GEO using GSE130973.
I know this code has worked for others, but for some reason, it is throwing an error for me.
I have included the error output as a screenshot, but will also include it here:
RInterpreterError Traceback (most recent call last) Cell In[101], line 1 ----> 1 get_ipython().run_cell_magic('R', '-o healthy', 'seurat_object <- readRDS("ref_data/GSE130973_seurat_analysis_lyko.rds")\nseurat_object <- CreateSeuratObject(counts = assay(rse, "counts"), meta.data = as.data.frame(colData(rse)))\nhealthy <- as.SingleCellExperiment(seurat_object)\n')
File /Applications/anaconda3/lib/python3.12/site-packages/IPython/core/interactiveshell.py:2541, in InteractiveShell.run_cell_magic(self, magic_name, line, cell) 2539 with self.builtin_trap: 2540 args = (magic_arg_s, cell) -> 2541 result = fn(*args, **kwargs) 2543 # The code below prevents the output from being displayed 2544 # when using magics with decorator @output_can_be_silenced 2545 # when the last Python token in the expression is a ';'. 2546 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File /Applications/anaconda3/lib/python3.12/site-packages/rpy2/ipython/rmagic.py:984, in RMagics.R(self, line, cell, local_ns) 982 if not e.stdout.endswith(e.err): 983 print(e.err) --> 984 raise e 985 finally: 986 if self.device in DEVICES_STATIC:
File /Applications/anaconda3/lib/python3.12/site-packages/rpy2/ipython/rmagic.py:949, in RMagics.R(self, line, cell, local_ns) 947 return_output = False 948 else: --> 949 text_result, result, visible = self.eval(code) 950 text_output += text_result 951 if visible:
File /Applications/anaconda3/lib/python3.12/site-packages/rpy2/ipython/rmagic.py:413, in RMagics.eval(self, code) 410 except (ri.embedded.RRuntimeError, ValueError) as exception: 411 # Otherwise next return seems to have copy of error. 412 warning_or_other_msg = self.flush() --> 413 raise RInterpreterError(code, str(exception), 414 warning_or_other_msg) 415 finally: 416 ro._print_deferred_warnings()
RInterpreterError: Failed to parse and evaluate line 'seurat_object <- readRDS("ref_data/GSE130973_seurat_analysis_lyko.rds")\nseurat_object <- CreateSeuratObject(counts = assay(rse, "counts"), meta.data = as.data.frame(colData(rse)))\nhealthy <- as.SingleCellExperiment(seurat_object)\n'. R error message: 'Error: unable to find an inherited method for function ‘assay’ for signature ‘x = "Seurat", i = "character"’'