[BioC] variable as argument to makeContrasts (limma)

Georg Otto georg.otto at tuebingen.mpg.de
Wed Jun 3 20:09:38 CEST 2009


Martin Morgan <mtmorgan at fhcrc.org> writes:

>>
>> Georg Otto wrote:
>>> Hi,
>>>
>>> maybe this is a more general R programming question, but I first try it
>>> here, because the problem occured to me with limma:
>>>
>>> I use the function makeContrasts
>>>
>>> makeContrasts(...,levels=design)
>>>
>>> like this
>>>
>>> makeContrasts(B-A,C-B,C-A,levels=design)
>>>
>>>
>>> now instead of giving explicitely "B-A,C-B,C-A" I would like to replace
>>> this by a variable, eg:
>>>
>>> a<-c("B-A","C-B","C-A")
>>>
>>> makeContrasts(a,levels=design)
>>>
>>> unfortunately, this does not work.
>
> One way is to aim for
>
>   do.call(makeConstrasts, myargs)
>
> where the 'myargs' is a list that you can construct any way you like, e.g.,
>
>   myargs = list("B-A", "C-B", "C-A", levels=design)
>   do.call(makeContrasts, myargs)
>

thanks a lot, that helps, but there comes up another problem:

I start with a character vector, from which I have to construct the
list:

> contrast.vector
[1] "First=B-A"  "Second=D-C"

How do I get from there to:

myargs = list(First="B-A", Second="D-C", levels=design)

Any hint will be appreciated,

Georg



More information about the Bioconductor mailing list