-
Notifications
You must be signed in to change notification settings - Fork 0
Ragrawal fix semicolon #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9409634
fix
raagagrawal 8c2daa1
remove commented code
raagagrawal c9d677c
update NEWS and contributors
raagagrawal 9b95a6d
arguments written out
raagagrawal 7e701a2
save original vcf rsID for output
alkaZeltser 0fd71b7
add tests for semicolon-separated ID merge
alkaZeltser 7aff72b
handle duplicate rsIDs
alkaZeltser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,7 +5,8 @@ Version: 3.0.2 | |
| Authors@R: c( | ||
| person('Paul', 'Boutros', role = 'cre', email = '[email protected]'), | ||
| person('Nicole', 'Zeltser', role = 'aut', comment = c(ORCID = '0000-0001-7246-2771')), | ||
| person('Rachel', 'Dang', role = 'ctb')) | ||
| person('Rachel', 'Dang', role = 'ctb'), | ||
| person('Raag', 'Agrawal', role = 'ctb')) | ||
| Description: Simple and transparent parsing of genotype/dosage data | ||
| from an input Variant Call Format (VCF) file, matching of genotype | ||
| coordinates to the component Single Nucleotide Polymorphisms (SNPs) | ||
|
|
@@ -14,7 +15,7 @@ Description: Simple and transparent parsing of genotype/dosage data | |
| in accordance with the additive weighted sum of dosages model. Methods | ||
| are designed in reference to best practices described by | ||
| Collister, Liu, and Clifton (2022) <doi:10.3389/fgene.2022.818574>. | ||
| Depends: | ||
| Depends: | ||
| R (>= 4.2.0) | ||
| Imports: | ||
| vcfR, | ||
|
|
@@ -23,7 +24,7 @@ Imports: | |
| reshape2, | ||
| BoutrosLab.plotting.general, | ||
| lattice | ||
| Suggests: | ||
| Suggests: | ||
| knitr, | ||
| rmarkdown, | ||
| testthat (>= 3.0.0) | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -105,23 +105,19 @@ combine.vcf.with.pgs <- function(vcf.data, pgs.weight.data) { | |
| missing.snp.pgs.weight.data <- subset(missing.snp.merged.data, select = colnames(pgs.weight.data)); | ||
| rm(missing.snp.merged.data); | ||
|
|
||
| # Split VCF$ID column into separate rows for each rsID (multiple rsIDs are separated by ;) | ||
| # most efficient way to do this is to use the data.table package | ||
| # Split VCF$ID column into separate rows for each rsID (multiple rsIDs separated by ;) | ||
| if (any(grepl(';', vcf.data$ID))) { | ||
| data.table::setDT(vcf.data); | ||
| split.rsid.vcf.data <- merge( | ||
| x = vcf.data, | ||
| # split only entries with multiple rsIDs, save in new column, and merge back with the original data | ||
| y = vcf.data[grepl(';', get('ID')), unique(unlist(strsplit(as.character(get('ID')), ';', fixed = TRUE))), by = .(get('Indiv'), get('CHROM'), get('POS')) | ||
| ][,.(new.ID = get('V1'), get('Indiv'), get('CHROM'), get('POS'))], | ||
| by = c('CHROM', 'POS', 'Indiv'), | ||
| all = TRUE | ||
| split.rows <- strsplit( | ||
| as.character(vcf.data$ID), | ||
| ';', | ||
|
||
| fixed = TRUE | ||
| ); | ||
| # replace entries with multiple rsIDs with the new, split, rsID | ||
| split.rsid.vcf.data <- split.rsid.vcf.data[!is.na(new.ID), ID := new.ID][, new.ID := NULL]; | ||
| } else { | ||
| split.rsid.vcf.data <- vcf.data; | ||
| } | ||
| expanded.vcf <- vcf.data[rep(seq_len(nrow(vcf.data)), lengths(split.rows)), ] | ||
| expanded.vcf$ID <- unlist(split.rows) | ||
| split.rsid.vcf.data <- expanded.vcf | ||
| } else { | ||
| split.rsid.vcf.data <- vcf.data | ||
| } | ||
|
|
||
| # merge missing SNP data on split rsID | ||
| merged.vcf.with.missing.pgs.data <- merge( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great improvement on clarity. I noticed that the original iteration uses the
Indivcolumn, is that column not necessary or not always available?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we replicate all columns in the dataframe so we don't explicitely need to reference Indiv.