Commit 9689fc84 authored by Laura Denies's avatar Laura Denies
Browse files

Update AMR_MGE.R

parent 78d1317c
......@@ -41,11 +41,12 @@ AMR_Plasmid$Plasmid_prediction <- fct_explicit_na(AMR_Plasmid$Plasmid_prediction
## VirFinder
VirFinder <- read.delim(file = snakemake@input[[6]])
VirFinder <- VirFinder %>% select(1,3,4)
colnames(VirFinder)<- c("ContigID","VirFinder_score","VirFinder_pvalue" )
colnames(VirFinder)<- c("ContigID","VirFinder_score","VirFinder_pvalue" )
VirFinder <- VirFinder %>% filter(ContigID != "name")
VirFinder$VirFinder_pvalue <- as.numeric(as.character(VirFinder$VirFinder_pvalue))
VirFinder$VirFinder_score <- as.numeric(as.character(VirFinder$VirFinder_score))
VirFinder$VirFinder_prediction <- ifelse(VirFinder$VirFinder_pvalue <=0.05 & VirFinder$VirFinder_score >=0.70, "Phage", "-")
VirFinder$ContigID <- sprintf("%010d", VirFinder$ContigID)
## VirSorter
vs.pred <- read.csv(file = snakemake@input[[7]], quote="", header=FALSE)
......@@ -70,10 +71,6 @@ colnames(VirSorter)<- c("ContigID","VirSorter_prediction")
VirSorter$ContigID <- as.numeric(as.character(VirSorter$ContigID))
VirSorter$ContigID <- sprintf("%010d", VirSorter$ContigID)
## Combine Phage prediction
Phage_prediction <- merge(VirFinder, VirSorter, by="ContigID", all = TRUE)
Phage_prediction$VirSorter_prediction <- fct_explicit_na(Phage_prediction$VirSorter_prediction, na_level = "-")
# Combine AMR/MGE with Phage prediction
AMR_MGE <- merge(AMR_Plasmid, Phage_prediction, by="ContigID", all = TRUE)
AMR_MGE <- AMR_MGE %>% mutate_if(is.factor, fct_explicit_na, na_level = "-")
......@@ -92,4 +89,3 @@ AMR_MGE_report <- AMR_MGE_report %>% select(1,2,3,4,5,9)
write.csv(AMR_MGE_report, file=snakemake@output[[2]], row.names=FALSE)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment