Skip to content

Commit

Permalink
v0.17.10
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkimbrel committed Nov 8, 2024
1 parent 94901b0 commit 05cc6f7
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 39 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: qSIP2
Title: qSIP Analysis
Version: 0.17.9
Version: 0.17.10
Authors@R:
person("Jeff", "Kimbrel", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7213-9392"))
Expand Down
2 changes: 1 addition & 1 deletion R/add_taxonomy.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#'
#' @returns An updated `qsip_feature_data` with the taxonomy slot populated with a taxonomy dataframe.
#' @importFrom rlang :=
#'

add_taxonomy <- function(feature_object, taxa, feature_id) {

# make sure feature_object is the right type
Expand Down
27 changes: 12 additions & 15 deletions R/plot_filter_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#'
#' @param qsip_data_object (*qsip_data*)
#' @param return_type (*string, default: combined*) Changes the return type from a combined plot (*combined*), list of individual plots (*individual*) or list of dataframes (*dataframe*)
#' @param colors (*strings*) An optional color palette
#'
#' @export
#'
Expand All @@ -21,28 +20,26 @@

plot_filter_results <- function(qsip_data_object,
return_type = "combined",
colors = NULL) {
stopifnot("qsip_data_object should be class <qsip_data>" = "qsip_data" %in% class(qsip_data_object))
colors = lifecycle::deprecated()) {

if (!return_type %in% c("combined", "individual", "dataframe")) {
stop(glue::glue("return_type should be either one of 'combined', 'individual' or 'dataframe'"))
is_qsip_filtered(qsip_data_object, error = TRUE)

if (lifecycle::is_present(colors)) {
lifecycle::deprecate_warn("0.17.10", "plot_filter_results(colors)")
}

if (length(qsip_data_object@filter_results) == 0) {
stop(glue::glue("please run run_filter_feature() on qsip_data_object before plotting results"))
if (!return_type %in% c("combined", "individual", "dataframe")) {
stop(glue::glue("return_type should be either one of 'combined', 'individual' or 'dataframe'"))
}

# bind variables
source_mat_id <- fraction_call <- tube_rel_abundance <- n <- NULL

if (is.null(colors)) {
colors <- c(
"Fraction Passed" = "#2B92BE",
"Fraction Filtered" = "#BE572B",
"Zero Fractions" = "gray30"
)
}

colors <- c(
"Fraction Passed" = "#037bcf",
"Fraction Filtered" = "#BE572B",
"Zero Fractions" = "gray70"
)

by_abundance_df <- qsip_data_object@filter_results$fraction_filtered |>
dplyr::group_by(source_mat_id, fraction_call) |>
Expand Down
8 changes: 4 additions & 4 deletions R/qsip_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -595,19 +595,19 @@ S7::method(get_dataframe, qsip_data) <- function(x, type, original_headers = FAL

S7::method(print, qsip_source_data) <- function(x, ...) {
sd = x@data
print(glue::glue_col("<qSIP2::qsip_source_data>
print(glue::glue_col("<qsip_source_data>
source_material_id count: {green {length(unique(sd$source_mat_id))}}"))
}

S7::method(print, qsip_sample_data) <- function(x, ...) {
sd = x@data
print(glue::glue_col("<qSIP2::qsip_sample_data>
print(glue::glue_col("<qsip_sample_data>
source_material_id count: {green {length(unique(sd$source_mat_id))}}
sample_id count: {green {length(unique(sd$sample_id))}}"))
}

S7::method(print, qsip_feature_data) <- function(x, ...) {
print(glue::glue_col("<qSIP2::qsip_feature_data>
print(glue::glue_col("<qsip_feature_data>
feature_id count: {green {dim(x@data)[1]}}
sample_id count: {green {dim(x@data)[2] - 1}}
data type: {green {x@type}}"))
Expand All @@ -616,7 +616,7 @@ S7::method(print, qsip_feature_data) <- function(x, ...) {
S7::method(print, qsip_data) <- function(x, ...) {


print(glue::glue_col("<qSIP2::qsip_data>
print(glue::glue_col("<qsip_data>
group: {green {ifelse(is.null(x@filter_results$group), 'none', x@filter_results$group)}}
feature_id count: {green {length(get_feature_ids(x, filtered = is_qsip_filtered(x)))} of {dim(x@feature_data@data)[1]}}
sample_id count: {green {length(unique(x@sample_data@data$sample_id))}}
Expand Down
8 changes: 5 additions & 3 deletions man/plot_filter_results.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/qsip_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
There are 15 source_mat_ids, and they are all shared between the source and sample objects
There are 284 sample_ids, and they are all shared between the sample and feature objects
Output
<qSIP2::qsip_data>
<qsip_data>
group: none
feature_id count: 2030 of 2030
sample_id count: 284
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/qsip_sample_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
gradient_position = "Fraction", gradient_pos_density = "density_g_ml",
gradient_pos_amt = "avg_16S_g_soil", gradient_pos_rel_amt = "gradient_pos_rel_amt")
Output
<qSIP2::qsip_sample_data>
<qsip_sample_data>
source_material_id count: 15
sample_id count: 284

Expand All @@ -18,7 +18,7 @@
Message
<gradient_pos_rel_amt> not specified. Calculating using avg_16S_g_soil column
Output
<qSIP2::qsip_sample_data>
<qsip_sample_data>
source_material_id count: 15
sample_id count: 284

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/run_EAF_calculations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Code
run_EAF_calculations(qsip_normal_strict_resampled)
Output
<qSIP2::qsip_data>
<qsip_data>
group: none
feature_id count: 74 of 2030
sample_id count: 284
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/run_comparison_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
resamples = 100)
Output
$Drought
<qSIP2::qsip_data>
<qsip_data>
group: Drought
feature_id count: 305 of 2030
sample_id count: 284
Expand All @@ -15,7 +15,7 @@
growth: FALSE
$Normal
<qSIP2::qsip_data>
<qsip_data>
group: Normal
feature_id count: 239 of 2030
sample_id count: 284
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/run_feature_filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
In total, 257 unique feature_ids passed all fraction and source filtering requirements
Output
<qSIP2::qsip_data>
<qsip_data>
group: none
feature_id count: 257 of 2030
sample_id count: 284
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/run_growth_calculations.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Warning:
3968 resamplings have a negative EAF value or calculated labeled copy numbers less than 0. These values have been filtered out and added to @growth$negative_labeled
Output
<qSIP2::qsip_data>
<qsip_data>
group: Day 10
feature_id count: 358 of 364
sample_id count: 106
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/run_resampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Code
run_resampling(qsip_normal_strict_filtered, resamples = 100, with_seed = 21)
Output
<qSIP2::qsip_data>
<qsip_data>
group: none
feature_id count: 74 of 2030
sample_id count: 284
Expand All @@ -19,7 +19,7 @@
Message
Using random seed. For consistency, you can use the with_seed argument
Output
<qSIP2::qsip_data>
<qsip_data>
group: none
feature_id count: 74 of 2030
sample_id count: 284
Expand All @@ -35,7 +35,7 @@
Message
Using random seed. For consistency, you can use the with_seed argument
Output
<qSIP2::qsip_data>
<qsip_data>
group: none
feature_id count: 74 of 2030
sample_id count: 284
Expand All @@ -54,7 +54,7 @@
Warning:
NA unlabeled and NA labeled feature_ids had resampling failures. Run `get_resample_counts()` or `plot_successful_resamples()` on your <qsip_data> object to inspect.
Output
<qSIP2::qsip_data>
<qsip_data>
group: none
feature_id count: 74 of 2030
sample_id count: 284
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ qsip_normal_strict_filtered <- readRDS(test_path("fixtures", "qsip_normal_strict

test_that("works as expected", {
expect_true("ggplot" %in% class(plot_filter_results(qsip_normal_strict_filtered)))
expect_true("ggplot" %in% class(plot_filter_results(qsip_normal_strict_filtered,
colors = c("red", "blue", "black")
)))

expect_true("ggplot" %in% class(plot_filter_results(qsip_normal_strict_filtered,
return_type = "combined"
Expand Down

0 comments on commit 05cc6f7

Please sign in to comment.