Skip to content

Commit

Permalink
fix bug about reduction dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
stemangiola committed Oct 28, 2023
1 parent 67b61d5 commit 078bef9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,17 @@ setGeneric("reduce_dimensions", function(.data,
col_names = get_abundance_norm_if_exists(.data, .abundance)
.abundance = col_names$.abundance

# adjust top for the max number of features I have
if(top > .data |> distinct(!!.feature) |> nrow()){
warning(sprintf(
"tidybulk says: the \"top\" argument %s is higher than the number of features %s",
top,
.data |> distinct(!!.feature) |> nrow()
))

top = min(top, .data |> distinct(!!.feature) |> nrow())
}

# Validate data frame
if(do_validate()) {
validation(.data, !!.element, !!.feature, !!.abundance)
Expand Down
11 changes: 11 additions & 0 deletions R/methods_SE.R
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,17 @@ setMethod("cluster_elements",
if(.abundance |> quo_is_symbolic()) my_assay = quo_name(.abundance)
else my_assay = get_assay_scaled_if_exists_SE(.data)

# adjust top for the max number of features I have
if(top > nrow(.data)){
warning(sprintf(
"tidybulk says: the \"top\" argument %s is higher than the number of features %s",
top,
nrow(.data)
))

top = min(top, nrow(.data))
}

my_assay =
.data %>%

Expand Down
2 changes: 1 addition & 1 deletion man/get_reduced_dimensions_UMAP_bulk.Rd

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

2 changes: 1 addition & 1 deletion man/get_reduced_dimensions_UMAP_bulk_SE.Rd

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

0 comments on commit 078bef9

Please sign in to comment.