Closed QidiFeng closed 5 years ago
Hi Qidi
You're almost there I think. What is exactly model
in your case? Is this a dataframe retrieved by doing infer_trajectories()
?
Hi Wouter,
The model is a dataframe but not retrieved by doing infer_trajectories(). Since I want to compare the performance of multiple dimension reduction methods in trajectory inference, so I applied slingshot on results from multiple dimension reduction methods, and then wrap the results from slingshot to that model required by dynverse according to ti_slingshot.R in dynverse github (The code is attached below). I also gave a model example in the attachment. You may like to check it~
Code: slingout <- load(paste0(res_path,"slingshot.data",idata,".method",imethod,".RData")) #
####
lineages <- slingLineages(slingout) lineage_ctrl <- slingParams(slingout)
cluster_network <- lineages %>% map_df(~ tibble(from = .[-length(.)], to = .[-1])) %>% unique() %>% mutate( length = lineage_ctrl$dist[cbind(from, to)], directed = TRUE )
dimred <- reducedDim(slingout)
cluster <- slingClusterLabels(slingout)
adj <- slingAdjacency(slingout) lin_assign <- apply(slingCurveWeights(slingout), 1, which.max)
progressions <- map_df(seq_along(lineages), function(l) { ind <- lin_assign == l lin <- lineages[[l]] pst.full <- slingPseudotime(slingout, na = FALSE)[,l] pst <- pst.full[ind] means <- sapply(lin, function(clID){ stats::weighted.mean(pst.full, cluster[,clID]) }) non_ends <- means[-c(1,length(means))] edgeID.l <- as.numeric(cut(pst, breaks = c(-Inf, non_ends, Inf))) from.l <- lineages[[l]][edgeID.l] to.l <- lineages[[l]][edgeID.l + 1] m.from <- means[from.l] m.to <- means[to.l]
pct <- (pst - m.from) / (m.to - m.from)
pct[pct < 0] <- 0
pct[pct > 1] <- 1
tibble(cell_id = names(which(ind)), from = from.l, to = to.l,
percentage = pct) })
#
model <- dynwrap::wrap_data( cell_ids = rownames(expression) ) %>% dynwrap::add_trajectory( milestone_network = cluster_network, progressions = progressions ) %>% dynwrap::add_dimred( dimred = dimred ) save(model, file=paste0(res_path, "slingshot.model.data",idata,".method",imethod,".RData"))
On Wed, Aug 7, 2019 at 4:45 AM Wouter Saelens notifications@github.com wrote:
Hi Qidi
You're almost there I think. What is exactly model in your case? Is this a dataframe retrieved by doing infer_trajectories() ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dynverse/dyneval/issues/56?email_source=notifications&email_token=AJ6PSOGP2BWWRSSQMU4DDITQDKDSVA5CNFSM4IJO6OD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3XV3UA#issuecomment-519003600, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ6PSOEF2GK2P32Z3RUAU63QDKDSVANCNFSM4IJO6ODQ .
Hi Qidi
So model is just one model, all you have to do is model <- add_cell_waypoints(model)
:slightly_smiling_face:
Great! That did solve the problem, thank you very much!
Best, Qidi
On Fri, Aug 9, 2019 at 3:47 AM Wouter Saelens notifications@github.com wrote:
Hi Qidi
So model is just one model, all you have to do is model <- add_cell_waypoints(model) 🙂
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dynverse/dyneval/issues/56?email_source=notifications&email_token=AJ6PSOER2GBNT7XGQOC3BBDQDUOIHA5CNFSM4IJO6OD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD354VBY#issuecomment-519817863, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ6PSOBSBFZVMWZQ4YRMTZDQDUOIHANCNFSM4IJO6ODQ .
Awesome!
Hi, Dyneval group,
I tried to use "correlation" metric in calculate_metrics function. However, it reports that:
I tried to figure out the problem by adding cell waypoints by:
However, the error still exist. There is no errors reporting when I used other metrics. So I supposed this is not the problem regarding dataset or model. So any suggestions? Thank you very much!
Best, Qidi