I have am using the makeContrasts
function as part of a pipeline (with limma).
I have several studies, which are entered into the pipeline one after the other. For two of which, the makeContrasts functions looks like this:
aarts_1_cm = makeContrasts(R10d = labelR - labelP,
R1nMRap = labelR1 - labelP,
R10nMRap_OSKM = labelR10 - labelO,
levels = Design)
and
aarts_2_cm = makeContrasts(OSKM14 = labelO14 - labelP14,
OSKM14mTORsh_OSKM14p21sh = labelOT14 - labelOp14,
OSKM20mTORsh_OSKM20p21sh = labelOT20 - labelOp20,
levels = Design)
As the contrasts are different for each study, I cannot incorporate them into the pipeline. I have therefore turned the contents of the function into a string:
aarts_2 = "OSKM14 = labelO14 - labelP14,
OSKM14mTORsh_OSKM14p21sh = labelOT14 - labelOp14,
OSKM20mTORsh_OSKM20p21sh = labelOT20 - labelOp20,
levels = Design"
So that I can then do makeContrasts(unstring(aarts_2))
, but I don't know how to unstring aarts_2
so that the function will read it. Or if there is a better way to do this. I would appreciate any help with this.
Thanks.
I don't think there's a way to write the unstring
function you want, but you can do this:
makeContrastsFromString <- function(s)
eval(parse(text = paste("makeContrasts(", s, ")")))
then
makeContrastsFromString(aarts_2)
should give you want you want. I haven't tested it, since I can't install limma
to get makeContrasts
. My function is pretty fragile; if a user breaks up the lines into separate elements of a string vector, it won't work. I'll leave it to you to make it robust against that kind of thing.