Skip to content

Commit

Permalink
sortRegions now supports sort_strategy parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jrboyd committed Oct 4, 2024
1 parent ad1a980 commit d805470
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: chiptsne2
Type: Package
Title: ChIPseq analysis using tSNE
Version: 0.1.45
Version: 0.1.46
Authors@R: person("Joseph R", "Boyd", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID="0000-0002-8969-9676"))
Description: chiptsne2 provides support for tSNE and other dimensional
Expand Down
16 changes: 14 additions & 2 deletions R/functions_grouping.R
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ setMethod("groupRegionsByValues", c("ChIPtsne2_no_rowRanges"), .groupRegionsByVa

#### sort regions ####

.sortRegions = function(ct2, group_VAR = NULL){
.sortRegions = function(ct2,
sort_strategy = c("hclust", "sort", "left", "right", "none", "reverse")[2],
group_VAR = NULL){
message("sortRegions ...")
args = get_args()
prof_dt = getTidyProfile(ct2, meta_VARS = group_VAR)
Expand All @@ -530,6 +532,7 @@ setMethod("groupRegionsByValues", c("ChIPtsne2_no_rowRanges"), .groupRegionsByVa
fill_ = ct2@value_VAR,
facet_ = ct2@name_VAR,
cluster_ = group_VAR,
within_order_strategy = sort_strategy,
dcast_fill = 0)
region_lev = levels(clust_dt[[ct2@region_VAR]])
history_item = list(sortRegions = list(FUN = .sortRegions , ARG = args))
Expand All @@ -542,6 +545,13 @@ setMethod("groupRegionsByValues", c("ChIPtsne2_no_rowRanges"), .groupRegionsByVa
#' sortRegions
#'
#' @param ct2 `r doc_ct2_nrr()`
#' @param sort_strategy Strategy to use for sorting within groups. Valid choices
#' are: 1) "sort", which sorts decreasing top to bottom, 2) "hclust" which
#' uses hierarchical clustering, 3) "left" which puts most left tiled profiles
#' at top, and 4) "right" which puts most right tilted profiles at top. 5)
#' "none" does no new sorting and relies on current order set by
#' `sortRegions`. 6) "reverse" is like "none" but the current rder will be
#' reversed. c("hclust", "sort", "left", "right", "none", "reverse")[2]
#' @param group_VAR `r doc_group_VAR()`
#'
#' @return `r doc_ct2_nrr()` with rows sorted by `group_VAR` and within groups by signal decreasing.
Expand All @@ -557,7 +567,9 @@ setMethod("groupRegionsByValues", c("ChIPtsne2_no_rowRanges"), .groupRegionsByVa
#' ct2.sorted2 = sortRegions(ct2, group_VAR = c("peak_MCF10AT1_CTCF", "peak_MCF10CA1_CTCF"))
#' rowData(ct2.sorted2)
setGeneric("sortRegions",
function(ct2, group_VAR = NULL)
function(ct2,
sort_strategy = c("hclust", "sort", "left", "right", "none", "reverse")[2],
group_VAR = NULL)
standardGeneric("sortRegions"),
signature = "ct2")

Expand Down
5 changes: 4 additions & 1 deletion R/functions_plot_heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@
#' @param sort_strategy Strategy to use for sorting within groups. Valid choices
#' are: 1) "sort", which sorts decreasing top to bottom, 2) "hclust" which
#' uses hierarchical clustering, 3) "left" which puts most left tiled profiles
#' at top, and 4) "right" which puts most right tilted profiles at top.
#' at top, and 4) "right" which puts most right tilted profiles at top. 5)
#' "none" does no new sorting and relies on current order set by
#' `sortRegions`. 6) "reverse" is like "none" but the current rder will be
#' reversed. c("hclust", "sort", "left", "right", "none", "reverse")[2]
#' @param heatmap_fill_limits Passed to limits of scale_fill_gradientn. Default
#' of c(NA, NA) uses natural range of the data.
#' @param heatmap_colors Either a scale_fill_* or vector of R colors passed to
Expand Down
20 changes: 18 additions & 2 deletions man/ct2-sort.Rd

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

5 changes: 4 additions & 1 deletion man/plotSignalHeatmap.Rd

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

0 comments on commit d805470

Please sign in to comment.