Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to export bed file with metadata colums? #7

Open
kmatlik opened this issue May 8, 2020 · 1 comment
Open

Is it possible to export bed file with metadata colums? #7

kmatlik opened this issue May 8, 2020 · 1 comment
Assignees
Labels
question Further information is requested resolved Issue is resolved

Comments

@kmatlik
Copy link

kmatlik commented May 8, 2020

For example:

test <- GRanges(seqnames = c("chr1", "chr2", "chr3"),  
                ranges = IRanges(start = c(1,1,1),  
                                 end = c(100, 200, 300)),  
                expression = c(1000, 1500, 2000))  
export.bed(test, "~/Documents/test.bed")

But the resulting bed file doesn't have the "expression" column. Is it possible to keep the metadata columns too?
Thanks!

@matthew-paul-2006 matthew-paul-2006 self-assigned this Jul 30, 2020
@matthew-paul-2006 matthew-paul-2006 added the question Further information is requested label Jul 30, 2020
@matthew-paul-2006
Copy link

If you were had a GRange that matched a standard modified bed file format like narrowpeak, you could specify the filetype. But rtracklayer only really handles standard formats. I think this makes sense as BED files do not typically have headers, so you need a standardized format to be able to intuit what each column contains.

You can probably guess the work around then for your customized BED file. As we have covered GRanges can be converted into data.frames. Once coerced they can be written out with standard methods to standard formats that will preserve header information:

write.csv(as.data.frame(test), "~/Documents/test.bed")

The issue then becomes reading it back, as it will not go straight into a GRange object again . You could as an alternative write out as a TSV file, and drop the headers. Then import.bed will happily work. But the TSV will not have column information.

So it is a trade off.

@matthew-paul-2006 matthew-paul-2006 added the resolved Issue is resolved label Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested resolved Issue is resolved
Projects
None yet
Development

No branches or pull requests

2 participants