Reputation: 33
I am trying to save a .maf file as a table, but I always get the error below:
Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class ‘structure("MAF", package = "maftools")’ to a data.frame
This is the code I am using:
library(maftools)
laml.maf <- "/Users/PC/mc3.v0.2.8.PUBLIC.maf"
laml = read.maf(maf = laml.maf)
write.table(laml, file="/Users/PC/tp53atm.txt")
I understand that the .maf file has several fields, but I am not sure how to isolate them to save as a table. Any help would be much appreciated!
Upvotes: 3
Views: 1813
Reputation: 1076
The problem is, that the write.table
function doesn't know how to deal with an object of class MAF
.
However, you can access the underlying data like this:
write.table(laml@data, file="/Users/PC/tp53atm.txt")
But note that this way you will only export the raw data, whereas the MAF
object contains various other meta data:
> slotNames(laml)
[1] "data" "variants.per.sample" "variant.type.summary" "variant.classification.summary"
[5] "gene.summary" "summary"
"maf.silent" "clinical.data"
>
Upvotes: 4