Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ get_reduced_dimensions_UMAP_bulk <-
of_samples = TRUE,
transform = log1p,
scale = TRUE,
calculate_for_pca_dimensions = 20,
calculate_for_pca_dimensions = min(20, top),
...) {

if(!is.null(calculate_for_pca_dimensions) & (
Expand Down
2 changes: 1 addition & 1 deletion R/functions_SE.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ get_reduced_dimensions_UMAP_bulk_SE <-
of_samples = TRUE,
transform = log1p,
scale = NULL, # This is only a dummy argument for making it compatibble with PCA
calculate_for_pca_dimensions = 20,
calculate_for_pca_dimensions = min(20, top),
...) {
# Comply with CRAN NOTES
. = NULL
Expand Down
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.