Skip to content

Commit

Permalink
Merge pull request #236 from jpquast/Fix-typos-and-style
Browse files Browse the repository at this point in the history
Fix typos and style
  • Loading branch information
jpquast authored Mar 25, 2024
2 parents 2937e0c + 2c4acd4 commit b59ff7a
Show file tree
Hide file tree
Showing 20 changed files with 211 additions and 184 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
* The default batchsize of `fetch_pdb()` was changed to 100 (from 200). This was done since more information is retrieved now, which slows to function down and is slightly improved when batch sizes are smaller.
* `try_query()` now only retries to retrieve information once if the returned message was "Timeout was reached". In addition, a `timeout` and `accept` argument have been added.
* The UniProt database has changed its API, therefore column names have changed as well as the format of data. We adjusted the `fetch_uniprot()` and `fetch_uniprot_proteome()` function accordingly. Please be aware that some columns names might have changed and your code might throw error messages if you did not adjust it accordingly.
* Some typo fixes. Thank you Steffi!

# protti 0.3.1

Expand Down
2 changes: 1 addition & 1 deletion R/barcode_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ barcode_plot <- function(data,
size = 0.7
) +
{
if (is.numeric(dplyr::pull(data, {{ colouring }}))){
if (is.numeric(dplyr::pull(data, {{ colouring }}))) {
ggplot2::scale_fill_gradientn(colours = fill_colour_gradient)

Check warning on line 127 in R/barcode_plot.R

View check run for this annotation

Codecov / codecov/patch

R/barcode_plot.R#L127

Added line #L127 was not covered by tests
} else {
ggplot2::scale_fill_manual(values = c(
Expand Down
185 changes: 93 additions & 92 deletions R/calculate_diff_abundance.R

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions R/calculate_go_enrichment.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ calculate_go_enrichment <- function(data,

if (!(plot_style %in% c("barplot", "heatmap"))) stop("Invalid plot_style. Available styles: barplot, heatmap")

Check warning on line 236 in R/calculate_go_enrichment.R

View check run for this annotation

Codecov / codecov/patch

R/calculate_go_enrichment.R#L236

Added line #L236 was not covered by tests

if(length(barplot_fill_colour) < 2) stop('Please provide at least two colours to "barplot_fill_colour"!')
if (length(barplot_fill_colour) < 2) stop('Please provide at least two colours to "barplot_fill_colour"!')

Check warning on line 238 in R/calculate_go_enrichment.R

View check run for this annotation

Codecov / codecov/patch

R/calculate_go_enrichment.R#L238

Added line #L238 was not covered by tests

if (!stringr::str_detect(plot_cutoff, pattern = "^(pval|adj_pval) (top\\d+|\\d+(\\.\\d+)?)$")) {
stop("Invalid format for plot_cutoff. Please provide the type (pval or adj_pval) followed by
Expand Down Expand Up @@ -520,7 +520,7 @@ if you used the right organism ID.", prefix = "\n", initial = ""))
{
if (!missing(group)) {
if (y_axis_free) {
if(facet_n_col == 1){
if (facet_n_col == 1) {
ggforce::facet_col(rlang::new_formula(NULL, rlang::enquo(group)), scales = "free_y", space = "free")

Check warning on line 524 in R/calculate_go_enrichment.R

View check run for this annotation

Codecov / codecov/patch

R/calculate_go_enrichment.R#L522-L524

Added lines #L522 - L524 were not covered by tests
} else {
ggplot2::facet_wrap(rlang::new_formula(NULL, rlang::enquo(group)), scales = "free_y", ncol = facet_n_col)

Check warning on line 526 in R/calculate_go_enrichment.R

View check run for this annotation

Codecov / codecov/patch

R/calculate_go_enrichment.R#L526

Added line #L526 was not covered by tests
Expand Down
8 changes: 4 additions & 4 deletions R/drc_4p_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ drc_4p_plot <- function(data,
) +
ggplot2::geom_point(size = 2, col = "#5680C1") +
{
if(nrow(input_curve_plot) != 1) {
if (nrow(input_curve_plot) != 1) {
ggplot2::geom_ribbon(
data = input_curve_plot,
ggplot2::aes(
Expand All @@ -188,7 +188,7 @@ drc_4p_plot <- function(data,
}
} +
{
if(nrow(input_curve_plot) != 1) {
if (nrow(input_curve_plot) != 1) {
ggplot2::geom_line(
data = input_curve_plot,
ggplot2::aes(
Expand Down Expand Up @@ -286,7 +286,7 @@ drc_4p_plot <- function(data,
ggplot2::ggplot(data = x, ggplot2::aes(x = {{ dose }}, y = {{ response }})) +
ggplot2::geom_point(size = 2, col = "#5680C1") +
{
if(nrow(y) != 1) {
if (nrow(y) != 1) {
ggplot2::geom_ribbon(
data = y,
ggplot2::aes(
Expand All @@ -301,7 +301,7 @@ drc_4p_plot <- function(data,
}
} +
{
if(nrow(y) != 1) {
if (nrow(y) != 1) {
ggplot2::geom_line(
data = y,
ggplot2::aes(
Expand Down
6 changes: 4 additions & 2 deletions R/fetch_chebi.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ fetch_chebi <- function(relation = FALSE, stars = c(3), timeout = 60) {

chebi_names_clean <- chebi_names %>%
dplyr::distinct(.data$COMPOUND_ID, .data$NAME, .data$TYPE) %>%
dplyr::rename(ID = "COMPOUND_ID",
TYPE_NAME = "TYPE") %>%
dplyr::rename(
ID = "COMPOUND_ID",
TYPE_NAME = "TYPE"
) %>%
dplyr::bind_rows(chebi_compounds_names_clean)

chebi <- chebi_compounds_clean %>%
Expand Down
2 changes: 1 addition & 1 deletion R/fetch_pdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ fetch_pdb <- function(pdb_ids, batchsize = 100, show_progress = TRUE) {

combined <- polymer_entities %>%
dplyr::full_join(nonpolymer_entities, by = c("pdb_ids", "auth_asym_ids"), relationship = "many-to-many") %>%
dplyr::left_join(rcsb_binding_affinity, by = "pdb_ids", relationship = "many-to-many" ) %>%
dplyr::left_join(rcsb_binding_affinity, by = "pdb_ids", relationship = "many-to-many") %>%
dplyr::left_join(additional_info, by = "pdb_ids") %>%
dplyr::left_join(crystal_growth_info, by = "pdb_ids") %>%
dplyr::left_join(nmr_info, by = "pdb_ids") %>%
Expand Down
28 changes: 16 additions & 12 deletions R/fit_drc_4p.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,23 @@ fit_drc_4p <- function(data,
list(unique(.data$n_vector_add_rev))[[1]][2]
)$pval <= 0.1) %>%
dplyr::ungroup() %>%
tidyr::replace_na(list("pval_vector" = TRUE,
"pval_vector_rev" = TRUE,
"pval_vector_add" = TRUE,
"pval_vector_add_rev" = TRUE,
"mean_vector" = 0,
"mean_vector_rev" = 0,
"mean_vector_add" = 0,
"mean_vector_add_rev" = 0)) %>%
tidyr::replace_na(list(
"pval_vector" = TRUE,
"pval_vector_rev" = TRUE,
"pval_vector_add" = TRUE,
"pval_vector_add_rev" = TRUE,
"mean_vector" = 0,
"mean_vector_rev" = 0,
"mean_vector_add" = 0,
"mean_vector_add_rev" = 0
)) %>%
dplyr::group_by({{ grouping }}) %>%
dplyr::mutate(mean_vector = min(.data$mean_vector) == .data$mean_vector,
mean_vector_rev = min(.data$mean_vector_rev) == .data$mean_vector_rev,
mean_vector_add = min(.data$mean_vector_add) == .data$mean_vector_add,
mean_vector_add_rev = min(.data$mean_vector_add_rev) == .data$mean_vector_add_rev) %>%
dplyr::mutate(
mean_vector = min(.data$mean_vector) == .data$mean_vector,
mean_vector_rev = min(.data$mean_vector_rev) == .data$mean_vector_rev,
mean_vector_add = min(.data$mean_vector_add) == .data$mean_vector_add,
mean_vector_add_rev = min(.data$mean_vector_add_rev) == .data$mean_vector_add_rev
) %>%
dplyr::mutate(dose_MNAR = ifelse((all((.data$lower_vector & .data$enough_replicates == FALSE & .data$mean_vector) |
(!.data$lower_vector & .data$enough_replicates == TRUE & !.data$mean_vector)) &
.data$pval_vector) |
Expand Down
2 changes: 1 addition & 1 deletion R/normalise.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ normalise <-
if (!(method %in% c("median"))) {
stop("Invalid method. Available methods: median")

Check warning on line 61 in R/normalise.R

View check run for this annotation

Codecov / codecov/patch

R/normalise.R#L61

Added line #L61 was not covered by tests
}

if (method == "median") {
median_normalised <- data %>%
dplyr::distinct() %>%
Expand Down
16 changes: 10 additions & 6 deletions R/qc_charge_states.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ qc_charge_states <-
if (interactive == FALSE) {
ggplot2::geom_text(
data = label_positions,
aes(y = label_y,
label = round(.data$charge_per, digits = 1)),
vjust = 1.5
aes(
y = label_y,
label = round(.data$charge_per, digits = 1)
),
vjust = 1.5
)
}
} +
Expand Down Expand Up @@ -192,9 +194,11 @@ qc_charge_states <-
if (interactive == FALSE) {
ggplot2::geom_text(
data = label_positions,
aes(y = label_y,
label = round(.data$charge_per, digits = 1)),
vjust = 1.5
aes(
y = label_y,
label = round(.data$charge_per, digits = 1)
),
vjust = 1.5
)
}
} +
Expand Down
2 changes: 1 addition & 1 deletion R/qc_data_completeness.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ qc_data_completeness <- function(data,
dplyr::group_by({{ sample }}) %>%
dplyr::summarise(completeness = sum(!is.na({{ intensity }})) / dplyr::n() * 100, .groups = "drop") %>%
dplyr::mutate({{ digestion }} := .y)
) %>%
) %>%
filter(.data$completeness > 0)
} else {
result <- data %>%
Expand Down
16 changes: 10 additions & 6 deletions R/qc_missed_cleavages.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ intensities or set remove_na_intensities to FALSE",
if (interactive == FALSE) {
ggplot2::geom_text(
data = label_positions,
aes(y = .data$label_y,
label = round(.data$mc_percent, digits = 1)),
vjust = 1.5
aes(
y = .data$label_y,
label = round(.data$mc_percent, digits = 1)
),
vjust = 1.5
)
}
} +
Expand Down Expand Up @@ -206,9 +208,11 @@ intensities or set remove_na_intensities to FALSE",
if (interactive == FALSE) {
ggplot2::geom_text(
data = label_positions,
aes(y = .data$label_y,
label = round(.data$mc_percent, digits = 1)),
vjust = 1.5
aes(
y = .data$label_y,
label = round(.data$mc_percent, digits = 1)
),
vjust = 1.5
)
}
} +
Expand Down
16 changes: 10 additions & 6 deletions R/qc_peptide_type.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ qc_peptide_type <- function(data,
ggplot2::geom_col(col = "black", size = 1) +
ggplot2::geom_text(
data = label_positions,
aes(y = label_y,
label = round(.data$peptide_type_percent, digits = 1)),
vjust = 1.5
aes(
y = label_y,
label = round(.data$peptide_type_percent, digits = 1)
),
vjust = 1.5
) +
ggplot2::labs(
title = "Peptide types per .raw file",
Expand Down Expand Up @@ -221,9 +223,11 @@ qc_peptide_type <- function(data,
ggplot2::geom_col(col = "black", size = 1) +
ggplot2::geom_text(
data = label_positions,
aes(y = label_y,
label = round(.data$peptide_type_percent, digits = 1)),
vjust = 1.5
aes(
y = label_y,
label = round(.data$peptide_type_percent, digits = 1)
),
vjust = 1.5
) +
ggplot2::labs(
title = "Peptide type intensity per .raw file",
Expand Down
2 changes: 1 addition & 1 deletion R/qc_proteome_coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ qc_proteome_coverage <- function(data,

proteome <- fetch_uniprot_proteome(organism_id, reviewed = reviewed)

if(is(proteome, "character")){
if (is(proteome, "character")) {
# UniProt information could not be fetched.
message("UniProt information could not be fetched")
return(NULL)
Expand Down
11 changes: 6 additions & 5 deletions R/qc_sequence_coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ qc_sequence_coverage <- function(data,
coverage,
sample = NULL,
interactive = FALSE) {

# Validate inputs
if (!all(c(rlang::as_name(rlang::enquo(protein_identifier)), rlang::as_name(rlang::enquo(coverage))) %in% colnames(data))) {
stop("Column names for protein_identifier and coverage must exist in the dataset.")

Check warning on line 52 in R/qc_sequence_coverage.R

View check run for this annotation

Codecov / codecov/patch

R/qc_sequence_coverage.R#L52

Added line #L52 was not covered by tests
Expand Down Expand Up @@ -76,10 +75,12 @@ qc_sequence_coverage <- function(data,
boundary = 0,
size = 1
) +
ggplot2::geom_vline(data = result %>% dplyr::distinct(.data$median_coverage, {{ sample }}),
mapping = aes(xintercept = .data$median_coverage),
linewidth = 1,
linetype = "dashed") +
ggplot2::geom_vline(
data = result %>% dplyr::distinct(.data$median_coverage, {{ sample }}),
mapping = aes(xintercept = .data$median_coverage),
linewidth = 1,
linetype = "dashed"
) +
ggplot2::labs(
title = "Protein coverage distribution",
x = "Coverage [%]",
Expand Down
2 changes: 1 addition & 1 deletion man/barcode_plot.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/calculate_diff_abundance.Rd

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

9 changes: 6 additions & 3 deletions man/qc_missed_cleavages.Rd

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

Loading

0 comments on commit b59ff7a

Please sign in to comment.