Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkimbrel committed Sep 13, 2023
1 parent 5fc92b6 commit 5f45468
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
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.3.3
Version: 0.3.4
Authors@R:
person("Jeff", "Kimbrel", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(get_sample_counts)
export(gradient_pos_density_validation)
export(gradient_position_validation)
export(isotope_validation)
Expand Down
45 changes: 45 additions & 0 deletions R/qsip_sample_object.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,48 @@ qsip_sample_object <- S7::new_class("qsip_sample_object",
qSIP2::gradient_position_validation(self@data %>% pull(self@gradient_position))
}
)






#' Plot qSIP sample data density curves
#'
#' @param x An object of `qsip_sample_object` class
#'
#' @export
#'

plot_sample_curves <- S7::new_generic("plot_sample_curves", "x")

S7::method(plot_sample_curves, qsip_sample_object) <- function(x) {
facet_formula = paste0("~", x@source_mat_id)

x@data |>
dplyr::filter(!is.na(!!as.name(x@gradient_position))) |>
dplyr::filter(!!as.name(x@gradient_pos_density) > 1.5) |>
dplyr::group_by(!!as.name(x@source_mat_id)) |>
dplyr::mutate(j = !!as.name(x@gradient_pos_amt) / sum(!!as.name(x@gradient_pos_amt))) |>
ggplot2::ggplot(aes(x = !!as.name(x@gradient_pos_density), y = j)) +
ggplot2::geom_point(aes(color = !!as.name(x@isotope))) +
ggplot2::geom_line(aes(color = !!as.name(x@isotope)), linewidth = 1) +
ggplot2::scale_color_manual(values = c("16" = "lightblue", "18" = "blue", "16O" = "lightblue", "18O" = "blue", "15" = "yellow")) +
ggplot2::facet_wrap(facet_formula, scales = "free")

}

#' Get sample counts from qSIP sample data
#'
#' @param x An object of `qsip_sample_object` class
#'
#' @export
#'

get_sample_counts <- S7::new_generic("get_sample_counts", "x")

S7::method(get_sample_counts, qsip_sample_object) <- function(x) {
x@data[x@source_mat_id] |>
dplyr::rename(source_mat_id = x@source_mat_id) |>
dplyr::count(source_mat_id)
}
14 changes: 14 additions & 0 deletions man/get_sample_counts.Rd

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

0 comments on commit 5f45468

Please sign in to comment.