Skip to content

Commit

Permalink
solving the problem of name with value NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiawei-Yu10 committed Dec 12, 2024
1 parent a04caaf commit f389c0c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/differentiationProbabilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ differentiationProbabilities <- function(
# add terminal states
probabilities <- rbind(probabilities, T_[abs_states_idx, abs_states_idx])
probabilities <- probabilities[order(c(trans_states_idx, abs_states_idx)), ]
return(probabilities)
return(list(probabilities,terminal_states))
}
6 changes: 5 additions & 1 deletion R/markovProbability.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,18 @@ markovProbability <- function(
waypoints <- .maxMinSampling(multiscale, num_waypoints = 500)
waypoints <- unique(c(root_cell, waypoints, terminal_state))
# calculate probabilities
probabilities <- differentiationProbabilities(multiscale[waypoints, ],
probabilities_terminal <- differentiationProbabilities(multiscale[waypoints, ],
terminal_states = terminal_state,
knn = knn, pseudotime = diffusiontime, waypoints = waypoints
)
probabilities <- probabilities_terminal[[1]]
terminal_state <- probabilities_terminal[[2]]
# project probabilities from waypoints to each pseudobulk
probabilities_proj <- projectProbability(diffusionmap, waypoints, probabilities)
# store the result into milo
new_coldata <- DataFrame(probabilities_proj[, 1], probabilities_proj[, 2])
if(is.null(names(terminal_state)))
names(terminal_state) <- paste0("terminal_state", length(terminal_state))
colnames(new_coldata) <- c(names(terminal_state))
# prevent same name in colData
idx <- names(colData(milo)) %in% colnames(new_coldata)
Expand Down
2 changes: 1 addition & 1 deletion man/markovProbability.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/vignette_02.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ plotPCA(pb.milo, color_by = "pseudotime") + scale_colour_gradientn(colours = pal
### Markov chain construction on the pseudobulk VDJ feature space

```{r}
pb.milo <- markovProbability(
pb.milo1 <- markovProbability(
milo = pb.milo,
diffusionmap = dm,
terminal_state = branch.tips,
Expand Down

0 comments on commit f389c0c

Please sign in to comment.