i have a csv file with DNA sequences. The file has 4 columns which are the name of the chromosome, the start and end of the sequence and the strand (missing or +). I want to transorme this file in fasta format with Rstudio and with the tool of biostring. But i don't know much about the code whick i have to use. First i download the library of biostring. i use this code: c
sv = read.csv("foo.csv")
fa = character(4 * nrow(csv))
fa[c(TRUE, FALSE)] = sprintf("> %s", csv$chr)
fa[c(FALSE, TRUE)] = csv$seq
writeLines(fa, "foo.fasta")
library(Biostrings)
seq = csv$seq
names(seq) = csv$id
dna = DNAStringSet(seq)
write.XStringSet(dna, "foo.fasta").
also when i run the code: fa[c(TRUE, FALSE)] = sprintf("> %s", csv$chr)
, it appears ---Error in fa[c(TRUE, FALSE)] = sprintf("> %s", csv$chr) :
replacement has length zero
do you reccomend me some other code? or what should change in this code.
Thank you