forked from dynverse/dynmethods
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 052e938
Showing
84 changed files
with
5,187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
Package: dynmethods | ||
Type: Package | ||
Title: Wrappers for trajectory inference methods | ||
Version: 0.1.0 | ||
Authors@R: c( | ||
person("Robrecht", "Cannoodt", email = "[email protected]", role = c("aut", "cre")), | ||
person("Wouter", "Saelens", email = "[email protected]", role = c("aut")), | ||
person("Helena", "Todorov", email = "[email protected]", role = c("aut"))) | ||
Description: dynmethods provides wrappers for TI methods and their respective plotting functions. | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 6.0.1 | ||
Depends: | ||
R (>= 3.4.0) | ||
Imports: | ||
coRanking, | ||
cowplot, | ||
dplyr, | ||
dynplot, | ||
dynutils, | ||
GA, | ||
GEDEVO, | ||
ggforce, | ||
ggplot2, | ||
grDevices, | ||
grid, | ||
igraph, | ||
jsonlite, | ||
magrittr, | ||
methods, | ||
mlr, | ||
mlrMBO, | ||
netdist, | ||
parallelMap, | ||
ParamHelpers, | ||
pbapply, | ||
pdist, | ||
pheatmap, | ||
PRISM, | ||
purrr, | ||
randomForest, | ||
RColorBrewer, | ||
readr, | ||
reshape2, | ||
smoof, | ||
stringr, | ||
testthat, | ||
tibble, | ||
tidyr, | ||
viridis, | ||
vegan | ||
Suggests: | ||
Biobase, | ||
BiocGenerics, | ||
cellTree, | ||
coda, | ||
destiny, | ||
diffusionMap, | ||
dyntoy, | ||
embeddr, | ||
fastICA, | ||
GPfates, | ||
lle, | ||
MASS, | ||
Matrix, | ||
Mpath, | ||
mfa, | ||
monocle, | ||
ouija, | ||
phenopath, | ||
pseudogp, | ||
Rtsne, | ||
rstan, | ||
roxygen2, | ||
scater, | ||
SCORPIUS, | ||
SCOUP, | ||
SCUBA, | ||
SLICE, | ||
SLICER, | ||
slingshot, | ||
StemID, | ||
topslam, | ||
TSCAN, | ||
Waterfall, | ||
Wishbone, | ||
MCMCglmm | ||
Remotes: | ||
alan-turing-institute/network-comparison, | ||
berndbischl/ParamHelpers@dd54fe2719492dc0a03c6fe277d6ccaf255f6200, | ||
bioc::Biobase, | ||
bioc::BiocGenerics, | ||
bioc::cellTree, | ||
bioc::destiny, | ||
bioc::scater, | ||
bioc::TSCAN, | ||
dynverse/GEDEVO, | ||
dynverse/GPfates, | ||
dynverse/monocle, | ||
dynverse/Mpath, | ||
dynverse/SCOUP, | ||
dynverse/SCUBA, | ||
dynverse/SLICE, | ||
dynverse/SLICER, | ||
dynverse/StemID, | ||
dynverse/topslam, | ||
dynverse/Waterfall, | ||
dynverse/Wishbone, | ||
kieranrcampbell/pseudogp, | ||
kieranrcampbell/embeddr, | ||
kieranrcampbell/mfa, | ||
kieranrcampbell/ouija, | ||
kieranrcampbell/phenopath, | ||
kstreet13/slingshot, | ||
mlr-org/mlr, | ||
rcannood/dynutils, | ||
rcannood/PRISM, | ||
rcannood/SCORPIUS, | ||
Zouter/dynplot, | ||
Zouter/dyntoy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(check_dependencies) | ||
export(description_celltree_gibbs) | ||
export(description_celltree_maptpx) | ||
export(description_celltree_vem) | ||
export(description_dpt) | ||
export(description_embeddr) | ||
export(description_gpfates) | ||
export(description_identity) | ||
export(description_mfa) | ||
export(description_monocle1_ica) | ||
export(description_monocle2_ddrtree) | ||
export(description_mpath) | ||
export(description_ouija) | ||
export(description_phenopath) | ||
export(description_pseudogp) | ||
export(description_random) | ||
export(description_scorpius) | ||
export(description_scoup) | ||
export(description_scuba) | ||
export(description_shuffle) | ||
export(description_slice) | ||
export(description_slicer) | ||
export(description_slingshot) | ||
export(description_stemid) | ||
export(description_topslam) | ||
export(description_tscan) | ||
export(description_waterfall) | ||
export(description_wishbone) | ||
export(execute_method) | ||
export(execute_method_internal) | ||
export(get_descriptions) | ||
import(ParamHelpers) | ||
import(dplyr) | ||
import(dynutils) | ||
import(ggplot2) | ||
import(methods) | ||
import(tibble) | ||
import(tidyr) | ||
importFrom(RColorBrewer,brewer.pal) | ||
importFrom(cowplot,plot_grid) | ||
importFrom(dplyr,bind_cols) | ||
importFrom(dynplot,process_dynplot) | ||
importFrom(ggforce,geom_arc_bar) | ||
importFrom(grDevices,colorRampPalette) | ||
importFrom(grDevices,rainbow) | ||
importFrom(grid,arrow) | ||
importFrom(igraph,degree) | ||
importFrom(igraph,distances) | ||
importFrom(igraph,get.vertex.attribute) | ||
importFrom(igraph,induced_subgraph) | ||
importFrom(magrittr,"%$%") | ||
importFrom(magrittr,"%<>%") | ||
importFrom(magrittr,set_colnames) | ||
importFrom(pdist,pdist) | ||
importFrom(purrr,"%>%") | ||
importFrom(purrr,discard) | ||
importFrom(purrr,keep) | ||
importFrom(purrr,map) | ||
importFrom(purrr,map_chr) | ||
importFrom(purrr,map_dbl) | ||
importFrom(purrr,map_df) | ||
importFrom(purrr,map_int) | ||
importFrom(purrr,map_lgl) | ||
importFrom(purrr,set_names) | ||
importFrom(readr,read_csv) | ||
importFrom(readr,read_file) | ||
importFrom(readr,write_file) | ||
importFrom(reshape2,melt) | ||
importFrom(stats,cor) | ||
importFrom(stats,dist) | ||
importFrom(stats,kmeans) | ||
importFrom(stats,median) | ||
importFrom(stats,na.omit) | ||
importFrom(stats,prcomp) | ||
importFrom(stats,quantile) | ||
importFrom(stats,runif) | ||
importFrom(stats,setNames) | ||
importFrom(stats,step) | ||
importFrom(stats,time) | ||
importFrom(stats,var) | ||
importFrom(stringr,str_length) | ||
importFrom(utils,capture.output) | ||
importFrom(utils,head) | ||
importFrom(utils,installed.packages) | ||
importFrom(utils,lsf.str) | ||
importFrom(utils,read.table) | ||
importFrom(utils,tail) | ||
importFrom(utils,write.table) | ||
importFrom(viridis,scale_colour_viridis) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
list_dimred_methods <- function() { | ||
list( | ||
pca = dimred_pca, | ||
mds = dimred_mds, | ||
tsne = dimred_tsne, | ||
ica = dimred_ica, | ||
lle = dimred_lle | ||
) | ||
} | ||
|
||
dimred <- function(x, method, ...) { | ||
methods <- list_dimred_methods() | ||
if (method %in% names(methods)) { | ||
meth <- methods[[method]] | ||
params <- list(x = x, ...) | ||
do.call(meth, params) | ||
} else { | ||
stop("Method ", sQuote(method), " not found.") | ||
} | ||
} | ||
|
||
process_dimred <- function(space, rn) { | ||
space <- as.matrix(space) | ||
dimnames(space) <- list(rn, paste0("Comp", seq_len(ncol(space)))) | ||
space | ||
} | ||
|
||
|
||
dimred_pca <- function(x, ndim = 3) { | ||
space <- prcomp(t(x))$rotation[,seq_len(ndim)] | ||
process_dimred(space, rownames(x)) | ||
} | ||
|
||
dimred_mds <- function(x, ndim = 3) { | ||
requireNamespace("SCORPIUS") | ||
space <- SCORPIUS::reduce_dimensionality(SCORPIUS::correlation_distance(x), ndim = ndim) | ||
process_dimred(space, rownames(x)) | ||
} | ||
|
||
dimred_tsne <- function(x, ndim = 3) { | ||
requireNamespace("SCORPIUS") | ||
requireNamespace("Rtsne") | ||
requireNamespace("stats") | ||
space <- Rtsne::Rtsne(stats::as.dist(SCORPIUS::correlation_distance(x)), dims = ndim, is_distance = TRUE)$Y | ||
process_dimred(space, rownames(x)) | ||
} | ||
|
||
dimred_ica <- function(x, ndim = 3) { | ||
requireNamespace("fastICA") | ||
space <- fastICA::fastICA(t(scale(t(x))), ndim)$S | ||
process_dimred(space, rownames(x)) | ||
} | ||
|
||
dimred_lle <- function(x, ndim = 3) { | ||
requireNamespace("lle") | ||
poss_k <- lle::calc_k(t(scale(t(x))), ndim) | ||
k <- poss_k$k[which.min(poss_k$rho)] | ||
space <- lle::lle(t(scale(t(x))), ndim, k)$Y | ||
process_dimred(space, rownames(x)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#' @importFrom pdist pdist | ||
project_cells_to_segments <- function( | ||
cluster_network, | ||
cluster_space, | ||
sample_space, | ||
sample_cluster, | ||
num_segments_per_edge = 100, | ||
milestone_rename_fun = NULL | ||
) { | ||
# collect information on cells | ||
space_df <- sample_space %>% | ||
as.data.frame %>% | ||
rownames_to_column("cell_id") %>% | ||
mutate(label = sample_cluster) | ||
|
||
# collect information on clusters | ||
centers_df <- cluster_space %>% | ||
as.data.frame %>% | ||
rownames_to_column("clus_id") | ||
|
||
# collect information on edges | ||
edge_df <- cluster_network %>% | ||
left_join(centers_df %>% rename(from = clus_id) %>% rename_if(is.numeric, function(x) paste0("from.", x)), by = "from") %>% | ||
left_join(centers_df %>% rename(to = clus_id) %>% rename_if(is.numeric, function(x) paste0("to.", x)), by = "to") | ||
|
||
# construct segments | ||
segment_df <- edge_df %>% | ||
rowwise() %>% | ||
do(data.frame( | ||
from = .$from, | ||
to = .$to, | ||
percentage = seq(0, 1, length.out = num_segments_per_edge), | ||
sapply(colnames(sample_space), function(x) { | ||
seq(.[[paste0("from.", x)]], .[[paste0("to.", x)]], length.out = num_segments_per_edge) | ||
}), | ||
stringsAsFactors = FALSE | ||
)) %>% | ||
ungroup() | ||
|
||
# calculate shortest segment piece for each cell | ||
segment_ix <- sapply(seq_len(nrow(sample_space)), function(i) { | ||
x <- sample_space[i,] | ||
la <- space_df$label[[i]] | ||
ix <- which(segment_df$from == la | segment_df$to == la) | ||
dis <- pdist::pdist(x, segment_df[ix,colnames(sample_space)]) | ||
wm <- which.min(as.matrix(dis)[1,]) | ||
ix[wm] | ||
}) | ||
|
||
# construct progressions | ||
progressions <- data.frame( | ||
cell_id = rownames(sample_space), | ||
segment_df[segment_ix,] %>% select(from, to, percentage), | ||
stringsAsFactors = TRUE | ||
) | ||
|
||
# collect milestone network and ids | ||
milestone_network <- edge_df %>% | ||
select(from, to, length, directed) | ||
milestone_ids <- rownames(cluster_space) | ||
|
||
# rename milestones | ||
if (!is.null(milestone_rename_fun)) { | ||
progressions <- progressions %>% mutate_at(c("from", "to"), milestone_rename_fun) | ||
milestone_network <- milestone_network %>% mutate_at(c("from", "to"), milestone_rename_fun) | ||
milestone_ids <- milestone_rename_fun(milestone_ids) | ||
edge_df <- edge_df %>% mutate_at(c("from", "to"), milestone_rename_fun) | ||
centers_df <- centers_df %>% mutate(clus_id = milestone_rename_fun(clus_id)) | ||
space_df <- space_df %>% mutate(label = milestone_rename_fun(label)) | ||
} | ||
|
||
lst( | ||
milestone_ids, | ||
milestone_network, | ||
progressions, | ||
space_df, | ||
centers_df, | ||
edge_df | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#' Wrappers for trajectory inference methods | ||
#' | ||
#' @import dplyr | ||
#' @import tidyr | ||
#' @import methods | ||
#' @import ParamHelpers | ||
#' @import tibble | ||
#' @import ggplot2 | ||
#' @import dynutils | ||
#' @importFrom dynplot process_dynplot | ||
#' @importFrom stats cor dist kmeans median prcomp quantile runif setNames step time | ||
#' @importFrom utils installed.packages head tail | ||
#' @importFrom purrr %>% map map_df map_chr map_lgl map_int map_dbl keep discard set_names | ||
#' @importFrom magrittr %<>% %$% | ||
#' | ||
#' @docType package | ||
#' @name dyneval | ||
NULL |
Oops, something went wrong.