Closed wfma closed 3 years ago
Hello @wfma!
Could you send me some data so that I can run your code myself?
Do you want to perform this step before or after running trajectory inference?
At the very least, you either can provide a dimred = dyndimred::dimred_mds, expression_source = standford.dyno$expression
arguments to let dyno compute a dimred using the probided function. In your example, I think what you want is simply model %>% add_dimred(dimred = stanford@reductions[["umap"]])
.
Kind regards, Robrecht
Hi Robrecht, thank you so much for getting back to me! I want to input my UMAP before trajectory inference. I tried exactly what you said and it didnt work.
> model <- model %>%
+ add_dimred(dimred = stanford@reductions[["umap"]])
Error in get_expression(dataset, expression_source) :
No expression found in trajectory, please provide the expression through the expression_source argument. This can be an expression or counts matrix, or a dataset containing the expression.
I also tried to specify the expression source:
> model <- model %>%
+ add_dimred(dimred = stanford@reductions[["umap"]],
+ expression_source = stanford.dyno$expression)
Error in dimred(expression) : could not find function "dimred"
I am happy to send you the rds and the script I am working on, whats a good email address for you?
Wei
hi there! I am still trying to import the UMAP from seurat, any updates on this front?
Thanks! Wei
Works for me:
get_data <- function(path, assay_counts='SCT', assay_data='integrated') {
obj <- get(load(path))
wrap_data <- wrap_expression(
counts = t(as.matrix(obj@assays[[assay_counts]]@counts)),
expression = t(as.matrix(obj@assays[[assay_data]]@data))
)
wrap_data <- add_dimred(
wrap_data,
dimred = as.matrix(obj@reductions$umap@cell.embeddings)
)
wrap_data
}
obj <- get_data('path/to/seurat/RData')
is_wrapper_with_dimred(obj) # returns True
amazing, thanks for getting back! :)
Hi, just an update (sorry for the delay). But I was able to import the seurat UMAP using your code chunk! I made slight modifications, but in case the next person needs it also:
object_counts <- Matrix::t(as(as.matrix(SEURATOBJ@assays$RNA@counts), 'sparseMatrix'))
object_expression <- Matrix::t(as(as.matrix(SEURATOBJ@assays$RNA@data), 'sparseMatrix'))
object_cellinfo <- SEURATOBJ@meta.data[["SingleR.labels"]] #optional, i needed the cell type IDs
dyno_object <- wrap_expression(
counts = object_counts,
expression = object_expression)
model <- infer_trajectory(SEURATOBJ, "slingshot")
model <- model %>%
add_dimred(dimred = as.matrix(SEURATOBJ@reductions$umap@cell.embeddings),
expression_source = dyno_object$expression)
plot_dimred(
model,
expression_source = dyno_object$expression,
grouping = object_cellinfo
)
Hi there, I want to import the same UMAP embedding from Seurat. Previously I transferred it into Monocle3 using the following line:
I tried doing something similar with the dyno obj but I am getting an argument issue.
I was just hoping to have consistent looking UMAPs in my analysis! Please help.