Skip to content

Commit

Permalink
fix bug when SNVs = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sigven committed Apr 23, 2024
1 parent 197eb2a commit c831770
Show file tree
Hide file tree
Showing 6 changed files with 459 additions and 443 deletions.
7 changes: 4 additions & 3 deletions pcgrr/R/input_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ load_somatic_cna <- function(
dplyr::desc(.data$GLOBAL_ASSOC_RANK)) |>
pcgrr::order_variants(pos_var = 'SEGMENT_START')

pcgrr::log4r_info("Generating data frame with hyperlinked variant/gene annotations")
pcgrr::log4r_info(
"Generating data frame with hyperlinked variant/gene annotations")

callset_cna[['variant_display']] <- callset_cna[['variant']] |>

dplyr::mutate(
SEGMENT = glue::glue(
"<a href='http://genome.ucsc.edu/cgi-bin/hgTracks?db={hgname}&position=",
Expand Down Expand Up @@ -275,7 +275,8 @@ load_somatic_snv_indel <- function(
## Make data frame with columns for display
## in HTML output

pcgrr::log4r_info("Generating data frame with hyperlinked variant/gene annotations")
pcgrr::log4r_info(
"Generating data frame with hyperlinked variant/gene annotations")


callset[['variant_display']] <- callset[['variant']] |>
Expand Down
37 changes: 23 additions & 14 deletions pcgrr/R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ generate_report <-
settings = settings
)

if(!(callset_snv$retained_info_tags == "None")){
rep$settings$conf$other$retained_info_tags <-
if(!(callset_snv$retained_info_tags == "None" |
callset_snv$retained_info_tags == "")){
rep$settings$conf$other$retained_vcf_info_tags <-
callset_snv$retained_info_tags
}

Expand Down Expand Up @@ -97,6 +98,7 @@ generate_report <-
pcg_report_signatures <-
pcgrr::generate_report_data_signatures(
variant_set = callset_snv$variant,
vstats = rep$content$snv_indel$vstats,
settings = settings,
ref_data = ref_data)

Expand Down Expand Up @@ -804,10 +806,14 @@ write_report_tsv <- function(report = NULL, variant_type = 'snv_indel'){
!is.null(report$content$cna) &
report$content$cna$eval == TRUE){

output_data <- as.data.frame(
report$content$cna$callset$variant |>
dplyr::select(dplyr::any_of(pcgrr::tsv_cols$cna))
)
if(!is.null(report$content$cna$callset)){
if(is.data.frame(report$content$cna$callset$variant)){
output_data <- as.data.frame(
report$content$cna$callset$variant |>
dplyr::select(dplyr::any_of(pcgrr::tsv_cols$cna))
)
}
}
}

## SNVs/InDels
Expand All @@ -821,23 +827,26 @@ write_report_tsv <- function(report = NULL, variant_type = 'snv_indel'){
snv_indel_cols, report$settings$conf$other$retained_vcf_info_tags)
}

output_data <- report$content$snv_indel$callset$variant |>
dplyr::select(
dplyr::any_of(snv_indel_cols))


if(!is.null(report$content$snv_indel$callset)){
if(is.data.frame(report$content$snv_indel$callset$variant)){
output_data <- as.data.frame(
report$content$snv_indel$callset$variant |>
dplyr::select(
dplyr::any_of(snv_indel_cols))
)
}
}
}

if(NROW(output_data) > 0){
readr::write_tsv(
output_data, file = fname, col_names = TRUE, append = FALSE,
output_data, file = fname,
col_names = TRUE, append = FALSE,
na = ".", quote = "none")
} else {
pcgrr::log4r_info(
paste0("No data to write to TSV file - '", variant_type,"'"))
}
#pcgrr::log4r_info("------")


}

Expand Down

0 comments on commit c831770

Please sign in to comment.