Converting character values from global environment to GFF file

I'm new to RStudio, and am asked to create a GFF file for a college course. I have a large character value ("orf_verified.gff") I created and see in the global environment, but I need to convert it to a GFF file. I tried to filter for values that contained "orf_classification=Verified" and that worked, but it ended up as a character value, not a GFF file. This is what I tried:

orf_verified.gff <- grep("orf_classification=Verified",gene_data$gffAttributes, = FALSE,perl = FALSE,value = TRUE,fixed = FALSE,useBytes = FALSE,invert = FALSE)

I apologize in advance for asking a basic question and appreciate any help you can give.

Hi @Cassidy_Turner,
Welcome to the RStudio Community Forum.

Looks like you are trying to write an object to disk in GFF format, as described here (for example):

If that is true, then you have your "GFF-like" object in R and you need to write it to a file in tab-separated format. Try something like this:

write.table(x=orf_verified.gff, file="testing.gff", sep="\t", row.names=FALSE)

Then look at that file to see if it meets your requirements (especially the column names which will probably be required by other software).

In future, when asking for help it's best if you supply a minimal reproducible example (MRE) which would include a sample of your data plus the code that is not working as you wanted.

p.s. Just noticed that your R object is a character string. To use write.table you will need to convert that into a dataframe. That may not be trivial if you are an R beginner - try posting a MRE for more help.


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.