Skip to content

Commit

Permalink
Fix what groupings of references the subclustering is done on.
Browse files Browse the repository at this point in the history
Updated expectations of the internally stored clustering information when plotting references to allow for results obtained with version between ~1.3 and this one to be plotted.
  • Loading branch information
GeorgescuC committed Dec 4, 2020
1 parent 41455ea commit 77a46c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions R/inferCNV_heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,12 @@ plot_cnv <- function(infercnv_obj,
# order so the current groups are shown and seperated.

ordered_names <- c()
if (all(name_ref_groups %in% infercnv_obj@tumor_subclusters$subclusters) || !is.null(infercnv_obj@tumor_subclusters$hc[["all_references"]])) {
if (!is.null(infercnv_obj@tumor_subclusters$hc[["all_references"]])) { # this allows runs made with some versions of infercnv to be plotted, but shouldn't be happening anymore
ordered_names <- infercnv_obj@tumor_subclusters$hc[["all_references"]]$labels[infercnv_obj@tumor_subclusters$hc[["all_references"]]$order]
split_groups <- rep(1, length(ordered_names))
ref_data <- ref_data[, ordered_names, drop=FALSE]
}
else if (all(name_ref_groups %in% infercnv_obj@tumor_subclusters$subclusters)) {
if (cluster_references) {
split_groups <- c()
for (i in seq_along(name_ref_groups)) {
Expand All @@ -992,11 +997,6 @@ plot_cnv <- function(infercnv_obj,
}
}
}
else {
ordered_names <- infercnv_obj@tumor_subclusters$hc[["all_references"]]$labels[infercnv_obj@tumor_subclusters$hc[["all_references"]]$order]
split_groups <- rep(1, length(ordered_names))
}

ref_data <- ref_data[, ordered_names, drop=FALSE]
}
else {
Expand Down
12 changes: 6 additions & 6 deletions R/inferCNV_tumor_subclusters.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ define_signif_tumor_subclusters <- function(infercnv_obj, p_val, hclust_method,
tumor_groups <- c(infercnv_obj@observation_grouped_cell_indices, infercnv_obj@reference_grouped_cell_indices)
}
else {
if(length(infercnv_obj@reference_grouped_cell_indices) > 0) {
tumor_groups <- list(all_observations=unlist(infercnv_obj@observation_grouped_cell_indices, use.names=FALSE), all_references=unlist(infercnv_obj@reference_grouped_cell_indices, use.names=FALSE))
}
else {
tumor_groups <- list(all_observations=unlist(infercnv_obj@observation_grouped_cell_indices, use.names=FALSE))
}
# if(length(infercnv_obj@reference_grouped_cell_indices) > 0) {
tumor_groups <- c(list(all_observations=unlist(infercnv_obj@observation_grouped_cell_indices, use.names=FALSE)), infercnv_obj@reference_grouped_cell_indices)
# }c
# else {
# tumor_groups <- list(all_observations=unlist(infercnv_obj@observation_grouped_cell_indices, use.names=FALSE))
# }
}

for (tumor_group in names(tumor_groups)) {
Expand Down
12 changes: 6 additions & 6 deletions R/inferCNV_tumor_subclusters.random_smoothed_trees.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ define_signif_tumor_subclusters_via_random_smooothed_trees <- function(infercnv_
tumor_groups <- c(infercnv_obj@observation_grouped_cell_indices, infercnv_obj@reference_grouped_cell_indices)
}
else {
if(length(infercnv_obj@reference_grouped_cell_indices) > 0) {
tumor_groups <- list(all_observations=unlist(infercnv_obj@observation_grouped_cell_indices, use.names=FALSE), all_references=unlist(infercnv_obj@reference_grouped_cell_indices, use.names=FALSE))
}
else {
tumor_groups <- list(all_observations=unlist(infercnv_obj@observation_grouped_cell_indices, use.names=FALSE))
}
# if(length(infercnv_obj@reference_grouped_cell_indices) > 0) {
tumor_groups <- c(list(all_observations=unlist(infercnv_obj@observation_grouped_cell_indices, use.names=FALSE)), infercnv_obj@reference_grouped_cell_indices)
# }
# else {
# tumor_groups <- list(all_observations=unlist(infercnv_obj@observation_grouped_cell_indices, use.names=FALSE))
# }
}

res = list()
Expand Down

0 comments on commit 77a46c1

Please sign in to comment.