Skip to content

Commit

Permalink
more steps to finish qsip_sample_object creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkimbrel committed Sep 19, 2023
1 parent b620b6d commit 15eb340
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 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.4.1.9003
Version: 0.4.1.9005
Authors@R:
person("Jeff", "Kimbrel", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Expand Down
22 changes: 18 additions & 4 deletions R/qsip_sample_object.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,35 @@ qsip_sample_object <- S7::new_class(

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

S7::method(plot_sample_curves, qsip_sample_object) <- function(x) {
S7::method(plot_sample_curves, qsip_sample_object) <- function(x, colors = NULL) {

if (is.null(colors)) {
colors = c("12C" = "lightblue",
"13C" = "blue",
"14N" = "lightblue",
"15N" = "blue",
"16O" = "lightblue",
"18O" = "blue")
}

facet_formula = paste0("~", x@source_mat_id)

WAD = x@data %>%
dplyr::group_by(source_mat_id) %>%
dplyr::summarise(WAD = weighted.mean(density_g_ml, gradient_pos_rel_amt))

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(ggplot2::aes(x = !!as.name(x@gradient_pos_density),
y = !!as.name(x@gradient_pos_rel_amt),
color = !!as.name(x@isotope))) +
ggplot2::geom_point() +
ggplot2::geom_line(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")
ggplot2::scale_color_manual(values = colors) +
ggplot2::facet_wrap(facet_formula) +
ggplot2::geom_vline(data = WAD, linetype = 3, ggplot2::aes(xintercept = WAD))
}

#' Get sample counts from qSIP sample data
Expand Down
7 changes: 2 additions & 5 deletions R/remove_isotopolog_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
#'
#' @param data A dataframe or tibble
#'
#' @export
#'
#' @keywords sample_data
#'
#' @examples
#' \dontrun{
#' add_isotopolog_label(sample_data_nonMISIP, isotope = "isotope")
#' remove_isotopolog_label(sample_data_MISIP)
#' }
#'
#' @export

remove_isotopolog_label = function(data) {

Expand Down
3 changes: 3 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.onLoad <- function(...) {
S7::methods_register()
}
4 changes: 1 addition & 3 deletions man/remove_isotopolog_label.Rd

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

0 comments on commit 15eb340

Please sign in to comment.