Skip to content

Commit

Permalink
Merge branch 'release/0.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshah committed Jan 31, 2022
2 parents f774b31 + dcce96e commit e97c149
Show file tree
Hide file tree
Showing 3 changed files with 467 additions and 33 deletions.
2 changes: 1 addition & 1 deletion R/filter_calls.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ filter_calls = function(
# compiling different genotype files from step 1
fillouts.dt <- do.call(rbind,lapply(fillouts.filenames,function(y){
sample.name = gsub('.*./|-ORG.*.','',y)
sample.type = sample.sheet[Sample_Barcode == sample.name]$Sample_Type
sample.type = unique(sample.sheet[Sample_Barcode == sample.name]$Sample_Type)

# t_alt_count,t_ref_count,t_depth these columns are useless, have to use duplex/simplex/standard columms
maf.file <- fread(y) %>%
Expand Down
44 changes: 12 additions & 32 deletions reports/template.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ if (dmp_id != "") {
```

```{r echo=FALSE, eval=show_text}
```{r echo=FALSE}
if (dmp_id != "") {
asis_output("# {{PATIENT_ID}} ({{DMP_ID}}) \n")
page_title = "{{PATIENT_ID}} ({{DMP_ID}})"
} else {
asis_output("# {{PATIENT_ID}} \n")
page_title = "{{PATIENT_ID}}"
}
```

---
title: "`r page_title`"
---

```{r echo=FALSE, eval=show_text}
if ("{{TUMOR_TYPE}}" != "") {
asis_output("### {{TUMOR_TYPE}} \n")
Expand Down Expand Up @@ -181,32 +185,29 @@ if (impact_ccf_file != "") {
## ACCESS variants ##
tab1<-accesstab[,c("Hugo_Symbol","Chromosome", "Start_Position", "Variant_Classification", "HGVSp_Short", "Reference_Allele", "Tumor_Seq_Allele2", "Hotspot", "DMP", "CH")]
tab2<-NULL
tab3 <- NULL
dmpsamples <- NULL
dmpsamples.ids <- NULL
if ('{{PLOT_IMPACT}}') {
tab2<-accesstab %>% select(matches("(__total|__DMP_Tumor)$"))
tab2<-accesstab %>% select(matches("(___total|___DMP_Tumor)$"))
colnames(tab2)<-gsub("___total","",colnames(tab2))
colnames(tab2)<-gsub("___DMP_Tumor","",colnames(tab2))
dmpsamples.ids <- accesstab %>% select(matches("__DMP_Tumor$"))
dmpsamples.ids <- accesstab %>% select(matches("___DMP_Tumor$"))
colnames(dmpsamples.ids)<-gsub("___DMP_Tumor","",colnames(dmpsamples.ids))
dmpsamples.ids <- colnames(dmpsamples.ids)
} else {
tab2<-accesstab %>% select(matches("__total$"))
tab2<-accesstab %>% select(matches("___total$"))
colnames(tab2)<-gsub("___total","",colnames(tab2))
tab3<-accesstab %>% select(matches("__DMP_(Tumor|Normal)$"))
tab3<-accesstab %>% select(matches("___DMP_(Tumor|Normal)$"))
colnames(tab3)<-gsub("___DMP_Tumor","",colnames(tab3))
colnames(tab3)<-gsub("___DMP_Normal","",colnames(tab3))
dmpsamples<-colnames(tab3)
}
cmo_sample_id_order<-metadata$sample_id[order(metadata$collection_date)]
cmo_sample_id_order<-cmo_sample_id_order[cmo_sample_id_order %in% colnames(tab2)]
tab2<-data.frame(tab2,check.names=FALSE)[,cmo_sample_id_order, drop=FALSE]
tab<-cbind(tab1,tab2)
if (!is.null(tab3)) {
tab<-cbind(tab,tab3)
Expand All @@ -215,29 +216,23 @@ tab$VarType <- "SNV_INDEL"
tab[grep("__",tab$Hugo_Symbol),"VarType"]<-"SV"
tab$Hugo_Symbol<- gsub("__","-",tab$Hugo_Symbol)
tab$Chromosome<-as.character(tab$Chromosome)
if (nrow(dmp) > 0) {
tabletoprint<-merge(tab, dmp, all.x=TRUE)
} else {
tabletoprint <- tab
}
## read CNA files ##
all.cna.files <- list.files(path = access_data_analysis_cna_dir, pattern = sample, full.names=TRUE)
cna<-do.call('rbind', lapply(all.cna.files,fread)) %>% rename(sample_id=Tumor_Sample_Barcode)
if( nrow(cna) > 0){
cna<-merge(cna, metadata,by=c("sample_id"))
cna$collection_date<-as.Date(cna$collection_date, format="%m/%d/%y")
cna$fc<-as.numeric(cna$fc)
}
```

```{r prepare_data}
## Get VAFs of variants ##
temp <- melt(tab, id=c("Hugo_Symbol","Chromosome", "Start_Position", "Variant_Classification", "HGVSp_Short", "Reference_Allele", "Tumor_Seq_Allele2", "Hotspot", "DMP", "CH", "VarType", dmpsamples)) %>% separate(col=value, into=c("num1", "num2", "num3"))
temp$vaf = as.numeric(temp$num1)/as.numeric(temp$num2)
temp$total=temp$num2
Expand All @@ -246,31 +241,22 @@ temp[which(temp$VarType=="SV"), "vaf"] = (as.numeric(tempsv$num1)+as.numeric(tem
temp[which(temp$VarType=="SV"), "total"]=tempsv$num3
temp$Chromosome <- as.character(temp$Chromosome)
temp$vaf=temp$vaf
if (nrow(dmp) > 0) {
# merge with DMP
combined <- merge(temp, dmp, all.x=TRUE) %>% rename(sample_id = variable)
} else {
combined <- temp %>% rename(sample_id = variable)
combined[, "clonality"] <- NA
}
final <- merge(combined, metadata, by=c("sample_id"), all.x=TRUE)
final$collection_date <- as.Date(final$collection_date, format="%m/%d/%y")
# Create a variant name column
final$VarName=paste(final$Hugo_Symbol, final$HGVSp_Short)
final[is.na(final$HGVSp_Short), "VarName"] <- paste0(final$Hugo_Symbol, " ", final$Chromosome, ":", final$Start_Position, " ", final$Reference_Allele, ">", final$Tumor_Seq_Allele2)[is.na(final$HGVSp_Short)]
final[is.na(final$HGVSp_Short) & nchar(final$Reference_Allele)>5,"VarName"] <- paste0(final$Hugo_Symbol, " ", final$Chromosome, ":", final$Start_Position, " ", substr(final$Reference_Allele,1,3),"..", ">", final$Tumor_Seq_Allele2)[is.na(final$HGVSp_Short)]
final[is.na(final$HGVSp_Short) & nchar(final$Tumor_Seq_Allele2)>5,"VarName"] <- paste0(final$Hugo_Symbol, " ", final$Chromosome, ":", final$Start_Position, " ", final$Reference_Allele,1,3, ">", substr(final$Tumor_Seq_Allele2,1,3),"..")[is.na(final$HGVSp_Short)]
final[which(final$VarType=="SV"),"VarName"]<-final$Hugo_Symbol[which(final$VarType=="SV")]
# Select variant colors
final$vaf<-round(final$vaf,4)
final<-final[!is.na(final$vaf),]
final$total<-as.numeric(final$total)
Expand All @@ -279,29 +265,23 @@ vafsum<-aggregate(final$vaf,by=list(VarName=final$VarName),FUN=sum)
final<-subset(final, !final$VarName %in% vafsum[which(vafsum$x==0),"VarName"])
varcolors<-c(gg_color_hue(length(unique(final$VarName))),"black")
names(varcolors)<-c(unique(final$VarName),"average")
tabletoprint<-unique(merge(unique(final[,c("Hugo_Symbol","Chromosome","Start_Position")]), tabletoprint, by=c("Hugo_Symbol","Chromosome","Start_Position")))
final_snv<-subset(final,final$VarType=="SNV_INDEL")
if ('{{COMBINE_ACCESS}}') {
final_snv$clonality <- "MSK-ACCESS"
} else {
final_snv[is.na(final_snv$clonality),"clonality"]<-"ACCESS-only"
final_snv$clonality<-factor(
final_snv$clonality, levels=c("CLONAL","SUBCLONAL","INDETERMINATE","ACCESS-only"))
}
if (!is.null(dmpsamples.ids)) {
final_snv[which(final_snv$sample_id %in% dmpsamples.ids), "clonality"] <- "IMPACT"
}
final_sv<-subset(final,final$VarType=="SV")
if (nrow(final_sv) > 0) {
final_sv[, "clonality"] = "ACCESS-only"
final_sv[which(final_sv$DMP=="Signed out"),"clonality"]="IMPACT"
}
xlimits<-c(min(final$collection_date)-10, max(final$collection_date)+10)
xbreaks<-final$collection_date
xlabels <- final$timepoint
Expand Down
Loading

0 comments on commit e97c149

Please sign in to comment.