Skip to content

Commit

Permalink
adding hisens purity to facets-qc output. also compile_cohort_annotat…
Browse files Browse the repository at this point in the history
…ions now includes manual review info
  • Loading branch information
cband committed Jun 6, 2020
1 parent 65236ec commit 5f76a73
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: facetsPreview
Title: Review and refit FACETS runs
Version: 2.1.2
Version: 2.1.4
Authors@R: person("First", "Last", email = "[email protected]", role = c("aut", "cre"))
Description: Review and refit FACETS runs
biocViews:
Expand Down
29 changes: 28 additions & 1 deletion R/compile_cohort_annotations.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ compile_cohort_annotations <- function(samples_to_annotate, output_prefix, ncore

## read from facets_qc.txt
qc_file = paste0(sample_path, '/facets_qc.txt')
review_file = paste0(sample_path, '/facets_review.manifest')

if (!file.exists(qc_file)) { return() }
if (!file.exists(qc_file)| !file.exists(review_file)) { return() }

qc_runs = fread(qc_file) %>% filter(fit_name != 'Not selected')

Expand All @@ -58,6 +59,32 @@ compile_cohort_annotations <- function(samples_to_annotate, output_prefix, ncore
fit = qc_runs %>% head(n=1)
}

reviews <-
fread(review_file) %>%
filter(fit_name == fit$fit_name) %>%
arrange(desc(date_reviewed)) %>%
select(fit_name, review_notes, reviewed_by, date_reviewed, use_only_purity_run, use_edited_cncf, reviewer_set_purity) %>%
head(n=1)

fit <-
fit %>%
left_join(reviews)

####
#### update purity and ploidy based on reviews;
####
fit <-
fit %>%
rowwise %>%
mutate(purity = ifelse(!is.na(reviewer_set_purity) & reviewer_set_purity != '',
reviewer_set_purity,
ifelse(!is.na(use_only_purity_run) & use_only_purity_run,
purity_run_Purity,
hisens_run_Purity))) %>%
mutate(ploidy = ifelse(!is.na(use_only_purity_run) & use_only_purity_run,
purity_run_Ploidy,
hisens_run_Ploidy))

return (fit)
}, .parallel = parallelize)
)
Expand Down
10 changes: 8 additions & 2 deletions R/generate_genomic_annotations.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ generate_genomic_annotations = function(sample_id, sample_path, config_file, reg
write.table(qc, paste0(prefix, '.qc.txt'), quote=F, row.names=F, sep='\t')

# Write gene level // use hisensitivity run
gene_level = facetsSuite::gene_level_changes(hisens_output, 'hg19') %>%
add_column(sample = sample_id, .before = 1)

if (r$use_only_purity_run) {
gene_level = facetsSuite::gene_level_changes(purity_output, 'hg19', 'em')
} else {
gene_level = facetsSuite::gene_level_changes(hisens_output, 'hg19', 'em')
}
gene_level = gene_level %>% add_column(sample = sample_id, .before = 1)

write.table(gene_level, paste0(prefix, '.gene_level.txt'), quote=F, row.names=F, sep='\t')

# Write arm level // use purity run
Expand Down
1 change: 1 addition & 0 deletions R/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ metadata_init <- function(sample_id, sample_path, progress = NULL, update_qc_fil
hisens_run_snp_nbhd = get0("hisens_snp.nbhd", ifnotfound = NA),
hisens_run_ndepth = get0("hisens_ndepth", ifnotfound = NA),
hisens_run_hisens = round_down(get0("hisens_hisens", ifnotfound = NA)),
hisens_run_Purity = round_down(get0("hisens_Purity", ifnotfound = NA)),
hisens_run_Ploidy = round_down(get0("hisens_Ploidy", ifnotfound = NA)),
hisens_run_dipLogR = round_down(get0("hisens_dipLogR", ifnotfound = NA)),

Expand Down
2 changes: 1 addition & 1 deletion example_facets_preview.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"verify_sshfs_mount" : "juno",
"r_script_path" : "/opt/common/CentOS_7-dev/bin/Rscript",
"facets_suite_lib": "/juno/work/ccs/shared/software/R_libs/facetsSuite/2.0.5/",
"facets_suite_lib": "/juno/work/ccs/shared/software/R_libs/facetsSuite/2.0.6/",
"facets_suite_run_wrapper": "/juno/work/ccs/shared/software/R_libs/facetsSuite/2.0.4/run-facets-wrapper.R",
"facets_qc_script": "/juno/work/ccs/bandlamc/git/facets-preview/facets_qc/v1.0/facets_fit_qc.R"
}

0 comments on commit 5f76a73

Please sign in to comment.