Skip to content

Commit

Permalink
v0.17.0 spike-in logic started
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkimbrel committed Oct 3, 2024
1 parent 65ee023 commit d776468
Show file tree
Hide file tree
Showing 12 changed files with 117 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.16.15
Version: 0.17.0
Authors@R:
person("Jeff", "Kimbrel", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7213-9392"))
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export(infer_source_data)
export(is_qsip_data)
export(is_qsip_data_list)
export(is_qsip_filtered)
export(jgi_feature_df)
export(jgi_sample_df)
export(jgi_source_df)
export(multi_qsip_wrapper)
export(multi_qsip_wrapper_launcher)
export(n_resamples)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# qSIP2 0.17.0

* New functions to work with JGI spike-ins

# qSIP2 0.16

* Added new vignettes
Expand Down
13 changes: 13 additions & 0 deletions R/jgi_feature_df.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#' Make a feature dataframe from a JGI coverage file
#'
#' @export

jgi_feature_df <- function(coverage_file) {
readr::read_csv(coverage_file, show_col_types = F) |>
tidyr::pivot_longer(
cols = c(dplyr::everything(), -Feature),
names_to = "sample_id",
values_to = "COVERAGE"
) |>
dplyr::rename("feature_id" = "Feature")
}
25 changes: 25 additions & 0 deletions R/jgi_sample_df.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#' Make a sample dataframe from JGI proposal file
#'
#' @export

jgi_sample_df <- function(file_path, skip = 27) {
readr::read_lines(proposal_file,
skip = skip
) |>
tibble::enframe() |>
dplyr::filter(stringr::str_detect(value, "^\\d+\\.\\d+")) |>
tidyr::separate(value, sep = "\t", into = c("Fraction", "Fraction_eluted_volume (uL)", "Fraction_density (g/mL)", "Eluted_DNA_concentration (ng/uL)", "Run_date", "Library_name", "Fastq_name", "Sequencing_project_ID", "Sequins_added (pg)", "Mix_type", "Raw_reads_count", "Filtered_reads_count")) |>
tidyr::separate(Fraction, sep = " ", into = c("Fraction", "sample_id")) |>
tidyr::separate(Fraction, sep = "\\.", into = c("SOURCE", "Fraction")) |>
dplyr::select(sample_id,
SOURCE,
gradient_pos = Fraction,
gradient_pos_density = `Fraction_density (g/mL)`,
eluted_volume_ul = `Fraction_eluted_volume (uL)`,
eluted_conc_ng_ul = `Eluted_DNA_concentration (ng/uL)`,
sequins_pg = `Sequins_added (pg)`,
MIX = Mix_type
) |>
dplyr::left_join(sources, by = "SOURCE") |>
dplyr::select(-SOURCE)
}
15 changes: 15 additions & 0 deletions R/jgi_source_df.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#' Make a source dataframe from JGI proposal file
#'
#' @export

jgi_source_df <- function(file_path, skip = 27) {
readr::read_lines(file_path,
skip = skip
) |>
tibble::enframe() |>
dplyr::filter(stringr::str_detect(value, "^\\d+\\. ")) |>
tidyr::separate(value, sep = "\t", into = c("Source_sample", "Source_sample_ID", "Sample_group", "Group ID", "Isotope_label", "SIP_combined_assembly_AP_ID")) |>
tidyr::separate(Source_sample, sep = " ", into = c("SOURCE", "SOURCE_ID")) |>
dplyr::mutate(SOURCE = stringr::str_remove(SOURCE, "\\.")) |>
dplyr::select(SOURCE, source_mat_id = SOURCE_ID, isotope = Isotope_label)
}
Binary file modified R/sysdata.rda
Binary file not shown.
6 changes: 6 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ reference:
- plot_EAF_values
- plot_growth_values

- title: Spike-In Controls
contents:
- jgi_source_df
- jgi_sample_df
- jgi_feature_df

- title: Datasets
contents:
- example_source_df
Expand Down
17 changes: 17 additions & 0 deletions data-raw/example_qsip_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ isotope_palette = c(
"16O" = "#037bcf", "18O" = "#ff0000"
)

# JGI
jgi_mixes <- readxl::read_excel("/Users/kimbrel1/Library/CloudStorage/OneDrive-LLNL/Documents/Soils_SFA/analysis/qSIP_refactor/JGI_spike_ins/JGI_mixes.xlsx") |>
tidyr::pivot_longer(
cols = tidyr::ends_with("stoichiometry"),
names_to = "MIX",
values_to = "STOICHIOMETRY"
) |>
tidyr::drop_na(STOICHIOMETRY) |>
dplyr::mutate(
MIX = stringr::str_remove(MIX, "_stoichiometry"),
MIX = stringr::str_remove(MIX, "MIX_")
) |>
dplyr::mutate(RATIO = STOICHIOMETRY / sum(STOICHIOMETRY), .by = MIX) |>
dplyr::rename(feature_id = ID) |>
dplyr::arrange(MIX)

# save
usethis::use_data(example_source_df, overwrite = TRUE)
usethis::use_data(example_sample_df, overwrite = TRUE)
Expand All @@ -135,3 +151,4 @@ usethis::use_data(example_qsip_growth_t0, overwrite = TRUE)
usethis::use_data(example_group_dataframe, overwrite = TRUE)

usethis::use_data(isotope_palette, overwrite = TRUE, internal = TRUE)
usethis::use_data(jgi_mixes, overwrite = TRUE, internal = TRUE)
11 changes: 11 additions & 0 deletions man/jgi_feature_df.Rd

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

11 changes: 11 additions & 0 deletions man/jgi_sample_df.Rd

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

11 changes: 11 additions & 0 deletions man/jgi_source_df.Rd

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

0 comments on commit d776468

Please sign in to comment.