mckellardw / scMuscle

The Cornell Single-Cell Muscle Project (scMuscle) aims to collect, analyze and provide to the research community skeletal muscle transcriptomic data
18 stars 4 forks source link

prediction.scores extraction #4

Closed skim245 closed 2 years ago

skim245 commented 2 years ago

I'm facing another error where I need prediction.scores to plot ridge plots for BayesPrism outputs.

Which slot do we use to extract the "prediction.scores"?
and also are there any easy ways to add these predicted cell type names in meta.data slot in seurat object?

Thank you in advance!

mckellardw commented 2 years ago

Could you include what code is giving you errors, and what the errors are? Happy to help, just need a little guidance

skim245 commented 2 years ago

Below is the code i used from Rscript note (visium_github_v1.R)

Ridge plots for BayesPrism outputs (theta values)

library(ggridges) tmp.df <- lapply(prediction.scores, as.data.frame) tmp.df[[1]]$injury <- "D2" tmp.df[[2]]$injury <- "D5" tmp.df[[3]]$injury <- "D7"

and getting this error:
Error in lapply(prediction.scores, as.data.frame) : object 'prediction.scores' not found

and i cross checked previous codes and we haven't setup 'prediction.scores'

mckellardw commented 2 years ago

Oh! Sorry, looks like I had mixed up the code, and put the chunk which generates ridge plots before the code that builds a data frame for ggplot. I think I fixed the order. The snippet you are looking for is this:

prediction.scores <- lapply(
  seu.list[2:4],
  FUN = function(SEU){
    prediction.scores <- t(GetAssayData(SEU, assay="sub_raw_deg_ted"))[,celltypes.order]
    return(prediction.scores)
  }
)

(line 306 in the updated version of R_scripts/visium)github_v1.R)

Let me know if you have any further issues!