I'm having trouble finding a solution regarding the storage of output from matchPWM(). I'd like to store the output in xlsx/csv/txt file format. Trying to convert to dataframe after unlist() returns the error 'unimplemented type 'list' in 'encodeelement'
pwm<-PWM(adc,type="prob",prior.params = c(A=0.25,C=0.25,G=0.25,T=0.25))
pwm
-4 -3 -2 -1 BP +1
A 0.05377283 0.005631321 -0.017774842 0.01002784 0.326073962 0.04033945
C 0.04510563 0.115371305 0.022894940 0.11125792 -0.021888223 0.09707738
G 0.02962736 0.016846775 -0.006567253 0.03466881 -0.058405298 0.03089362
T 0.11013323 0.100789643 0.240086200 0.08268447 -0.007141397 0.07032860
i<-makeGRangesFromDataFrame(intsd)
mcols(i)[1]<-intsd$GID
mcols(i)[2]<-DNAStringSet(intsd$FASTA)
ir<-resize(i,width=29,fix="end")
irs<-getSeq(genome,ir)
irs
DNAStringSet object of length 20734:
width seq names
[1] 29 TGGACGTTCCTGACTGTCACGATAGATAG VEintron1
[2] 29 ACTTGGCCATGTGCTAACAACTTCCATAG VEintron2
[3] 29 TTTCTTTACTTCCTAATTTGTCTTAATAG VEintron3
[4] 29 AGCGTTACTAATGAATTGTTTTTCCACAG VEintron4
[5] 29 TGATTGTGATGGAACTGATGGCAGAACAG VEintron5
... ... ...
[20730] 29 TGAGCAGTATTGAAGGCTGATCATTGCAG VEintron20730
[20731] 29 TGGAAGCGTCTAGAGCTAATCTCCCTTAG VEintron20731
[20732] 29 TGGAAGAGTTTAAAGCTAATTTGCCTTAG VEintron20732
[20733] 29 ATCCCTCCGTACATTTGACTGTTAGAAAG VEintron20733
[20734] 29 CGGCCGAAAACTCACAAACACCTGTTCAG VEintron20734
hitlist<-lapply(irs, FUN = matchPWM, min.score="90%", with.score=TRUE, pwm = pwm)
hitlist
$VEintron20730
Views on a 29-letter DNAString subject
subject: TGAGCAGTATTGAAGGCTGATCATTGCAG
views: NONE
$VEintron20731
Views on a 29-letter DNAString subject
subject: TGGAAGCGTCTAGAGCTAATCTCCCTTAG
views: NONE
$VEintron20732
Views on a 29-letter DNAString subject
subject: TGGAAGAGTTTAAAGCTAATTTGCCTTAG
views: NONE
$VEintron20733
Views on a 29-letter DNAString subject
subject: ATCCCTCCGTACATTTGACTGTTAGAAAG
views:
start end width
[1] 14 19 6 [TTTGAC]
$VEintron20734
Views on a 29-letter DNAString subject
subject: CGGCCGAAAACTCACAAACACCTGTTCAG
views:
start end width
[1] 10 15 6 [ACTCAC]
adf<-as.data.frame(do.call(cbind, hitlist))
Warning message:
In cbind(...) :
number of rows of result is not a multiple of vector length (arg 14)
VEintron20712 VEintron20713 VEintron20714 VEintron20722 VEintron20729
1 GCTCAC TTTCAC TTTCAC TCTGAC TTTCAA
2 GCTCAC TTTCAC TTTCAC TCTGAC TTTCAA
3 GCTCAC TTTCAC TTTCAC TCTGAC TTTCAA
4 GCTCAC TTTCAC TTTCAC TCTGAC TTTCAA
5 GCTCAC TTTCAC TTTCAC TCTGAC TTTCAA
write.table(adf,file="adf.txt")
Error in write.table(adf, file = "adf.txt") :
unimplemented type 'list' in 'EncodeElement'
out <- do.call(c, lapply(hitlist, function(x) as(x, "IRanges")))
Error in do.call(c, lapply(hitlist, function(x) as(x, "IRanges"))) : 'what' must be a function or character string
do.call does not like 'c'/concatenate for the 'what' argument. any other suggestions?
Here's a self contained reproducible example, using part of the example in
?matchPWM