-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from UMCUGenetics/release/DIMSv2.7.0
Release/DIMSv2.7.0
- Loading branch information
Showing
7 changed files
with
148 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
pipeline/scripts/AddOnFunctions/add_lab_id_and_onderzoeksnummer.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
add_lab_id_and_onderzoeksnummer <- function(df_metabs_helix) { | ||
# Split patient number into labnummer and Onderzoeksnummer | ||
for (row in 1:nrow(df_metabs_helix)) { | ||
df_metabs_helix[row,"labnummer"] <- gsub("^P|\\.[0-9]*", "", df_metabs_helix[row,"Patient"]) | ||
labnummer_split <- strsplit(as.character(df_metabs_helix[row, "labnummer"]), "M")[[1]] | ||
df_metabs_helix[row, "Onderzoeksnummer"] <- paste0("MB", labnummer_split[1], "/", labnummer_split[2]) | ||
} | ||
|
||
return(df_metabs_helix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
pipeline/scripts/AddOnFunctions/get_patient_data_to_helix.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
get_patient_data_to_helix <- function(metab_interest_sorted, metab_list_all){ | ||
# Combine Z-scores of metab groups together | ||
df_all_metabs_zscores <- bind_rows(metab_interest_sorted) | ||
# Change columnnames | ||
colnames(df_all_metabs_zscores) <- c("HMDB_name", "Patient", "Z_score") | ||
# Change Patient column to character instead of factor | ||
df_all_metabs_zscores$Patient <- as.character(df_all_metabs_zscores$Patient) | ||
|
||
# Delete whitespaces HMDB_name | ||
df_all_metabs_zscores$HMDB_name <- str_trim(df_all_metabs_zscores$HMDB_name, "right") | ||
|
||
# Split HMDB_name column on "nitine;" for match dims_helix_table | ||
df_all_metabs_zscores$HMDB_name_split <- str_split_fixed(df_all_metabs_zscores$HMDB_name, "nitine;", 2)[,1] | ||
|
||
# Combine stofgroepen | ||
dims_helix_table <- bind_rows(metab_list_all) | ||
# Filter table for metabolites for Helix | ||
dims_helix_table <- dims_helix_table %>% filter(Helix == "ja") | ||
# Split HMDB_name column on "nitine;" for match df_all_metabs_zscores | ||
dims_helix_table$HMDB_name_split <- str_split_fixed(dims_helix_table$HMDB_name, "nitine;", 2)[,1] | ||
dims_helix_table <- dims_helix_table %>% select(HMDB_name_split, Helix_naam, high_zscore, low_zscore) | ||
|
||
# Filter DIMS results for metabolites for Helix | ||
df_metabs_helix <- df_all_metabs_zscores %>% filter(HMDB_name_split %in% dims_helix_table$HMDB_name_split) | ||
# Combine dims_helix_table and df_metabs_helix, adding Helix codes etc. | ||
df_metabs_helix <- df_metabs_helix %>% left_join(dims_helix_table, by = join_by(HMDB_name_split)) | ||
|
||
df_metabs_helix <- df_metabs_helix %>% select(HMDB_name, Patient, Z_score, Helix_naam, high_zscore, low_zscore) | ||
|
||
return(df_metabs_helix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
is_diagnostic_patient <- function(patient_column){ | ||
# Check for Diagnostics patients with correct patientnumber (e.g. starting with "P2024M") | ||
diagnostic_patients <- grepl("^P[0-9]{4}M",patient_column) | ||
|
||
return(diagnostic_patients) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
output_for_helix <- function(protocol_name, df_metabs_helix){ | ||
|
||
# Remove positive controls | ||
df_metabs_helix <- df_metabs_helix %>% filter(is_diagnostic_patient(Patient)) | ||
|
||
# Add 'Vial' column, each patient has unique ID | ||
df_metabs_helix <- df_metabs_helix %>% | ||
group_by(Patient) %>% | ||
mutate(Vial = cur_group_id()) %>% | ||
ungroup() | ||
|
||
# Split patient number into labnummer and Onderzoeksnummer | ||
df_metabs_helix <- add_lab_id_and_onderzoeksnummer(df_metabs_helix) | ||
|
||
# Add column with protocol name | ||
df_metabs_helix$Protocol <- protocol_name | ||
|
||
# Change name Z_score and Helix_naam columns to Amount and Name | ||
change_columns <- c(Amount = "Z_score", Name = "Helix_naam") | ||
df_metabs_helix <- df_metabs_helix %>% rename(all_of(change_columns)) | ||
|
||
# Select only necessary columns and set them in correct order | ||
df_metabs_helix <- df_metabs_helix %>% | ||
select(c(Vial, labnummer, Onderzoeksnummer, Protocol, Name, Amount)) | ||
|
||
# Remove duplicate patient-metabolite combinations ("leucine + isoleucine + allo-isoleucin_Z-score" is added 3 times) | ||
df_metabs_helix <- df_metabs_helix %>% | ||
group_by(Onderzoeksnummer, Name) %>% distinct() %>% ungroup() | ||
|
||
return(df_metabs_helix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters