[BioC] consensusString Function
whuber at embl.de
Tue Apr 6 23:36:50 CEST 2010
Hi Erik, Herv'e
please always provide the output of sessionInfo(), and a complete
reproducible example (you let Heidi and the others guess that you're
talking about the Biostrings package).
With a more recent version of Biostrings, I get:
consensusString( DNAStringSet(c("AAAA","ACTG")) )
#  "AMWR"
consensusString( DNAStringSet(c("AAAB","ACTG")) )
# Error in FUN(newX[, i], ...) :
'ambiguityMap' is missing some combinations of row names
And going into the debugger where the error is caused, i.e. within the
function "consensusLetter", the expression
i <- paste(all_letters[col >= threshold], collapse = "")
is evaluated where
 "A" "C" "G" "T" "B" ## length is 5
 1 0 0 0 ## length is 4
 "AB" ## recycling rule was applied
which seems unintended and with some more insight will probably lead to
the fixing of a bug.
R version 2.12.0 Under development (unstable) (2010-04-06 r51617)
 LC_CTYPE=C LC_NUMERIC=C LC_TIME=C
 LC_COLLATE=C LC_MONETARY=C
 LC_PAPER=C LC_NAME=C LC_ADDRESS=C
 LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C
attached base packages:
 stats graphics grDevices datasets utils methods base
other attached packages:
 Biostrings_2.15.26 IRanges_1.5.74 fortunes_1.3-7
loaded via a namespace (and not attached):
Heidi Dvinge ha scritto:
> Hello Erik,
> unfortunately I'm not familiar with the Biostrings package, so I can't
> tell you why this doesn't work, but until someone else can answer, this
> seems to be a work-around.
> Apparently, consensusString doesn't handle Ns.
>> test <- DNAStringSet(c("AANN","ACTG"))
> Error in .local(x, ...) :
> 'threshold' must be a numeric in (0, 1/sum(rowSums(x) > 0)]
> If there are no Ns things are okay though.
>> test2 <- DNAStringSet(c("AAAA","ACTG"))
>  "AMWR"
> However, Ns seem acceptable if the consensus matrix is calculated first,
> although they might result in ?s where no consensus could be found.
>> test3 <- consensusMatrix(test)
>  "A???"
>> I am trying to get a consensus string for a DNAStringSet, but I am getting
>> an error. The documentation for consensusString says the argument "x" is
>> either a consensus matrix or an XStringSet. So this should work, right?:
>>> myDNAStringSet <- DNAStringSet(c("NNNN","ACTG"))
>> Error in .local(x, ...) :
>> 'threshold' must be a numeric in (0, 1/sum(rowSums(x) > 0)]
>> Specifying a threshold in the arguments doesn't seem to make a difference.
>> Bioconductor mailing list
>> Bioconductor at stat.math.ethz.ch
>> Search the archives:
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
More information about the Bioconductor