I'm trying to write an Rscript to run the phylogenetics package ape to run the same command on many input files and produce an output file for each one with a modified version of the original file name.
Here is the code I'm trying to use:
library(ape)
setwd("/home/wirenia/phylogenomics_projects/Monoplacophora /2014-09-10_Monoplacophora_fixed_alicut/pruned/OGs_with_LANT/manually_cleaned_alignments/2019-06-19_IQ-TREE_single-gene_trees/")
for (x in list.files(pattern="*.treefile")) {
tree <- read.tree(x)
tree$node.label <- NULL
write.tree(tree, file = x'.nobootstraps.tre')
}
The issue is clearly on the write.tree
line, but I can't figure out how to fix it. Here's the error message I'm getting:
Rscript remove_bootstrap_support_values_from_newick_trees.r
Error: unexpected string constant in:
"tree$node.label <- NULL
write.tree(tree, file = tree'.nobootstraps.tre'"
Execution halted
Any assistance would be greatly appreciated.
Thanks!
I believe you need :
write.tree(tree, file = paste(x, '.nobootstraps.tre'))
instead of your
write.tree(tree, file = x'.nobootstraps.tre'
R cannot concatenate strings like you try stringvariable"stringliteral"
If you have more bioinformatics related questions in the future I suggest moving to https://bioinformatics.stackexchange.com/, I think you will get much quicker replies there.