[BioC] variable as argument to makeContrasts (limma)
Martin Morgan
mtmorgan at fhcrc.org
Wed Jun 3 20:44:28 CEST 2009
Georg Otto wrote:
> 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"
I'm not sure that you want to start from there?
myargs <- list(First="B-A", Second="D-C")
or
x <- c("First=B-A", "Second=D-C")
namecontr <- strsplit(x, "=")
myargs <- lapply(namecontr, "[[", 2)
names(myargs) <- sapply(namecontr, "[[", 1)
myargs[["levels"]] <- design
but I wonder a bit what the 'bigger picture' is, since these kinds of
manipulations are not what one would do in a typical analysis.
Martin
>
> How do I get from there to:
>
> myargs = list(First="B-A", Second="D-C", levels=design)
>
> Any hint will be appreciated,
>
> Georg
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
More information about the Bioconductor
mailing list