need help on
1
0
Entering edit mode
Jianping Jin ▴ 890
@jianping-jin-1212
Last seen 9.6 years ago
Dear statisticians of the list, I am a limma user and have a small data set that I used the lme mixed effect model for analysis. I need some help in extracting comparisons from the result. I sent my questions to the R help list, but it appears that there is no people there care about the questions. I know my questions may not be related to this list, but if you would help could you please point me out what I can do or I should do something else? Your help will be greatly appreciated. My data set is similar to the example data, Orthodont, and I used patient subject as a random effect and did something below: library(nlme) library(gregmisc) data(Orthodont) Orthodont$AgeGroup <- gtools::quantcut(Orthodont$age) fm <- lme(distance ~ AgeGroup + Sex + AgeGroup*Sex, data = Orthodont, random = ~1|Subject) fit.contrast(fm, "Sex", c(-1,1), conf=0.95) fit.contrast(fm, "AgeGroup", rbind("1 vs 2"=c(-1,1,0,0), "2 vs 3"=c(0,-1,1,0)), conf=0.95) But how can I compare different age groups among Male, Female or between Male and Female as illustrated below (age groups on rows): ## comparison among Male Male Female [1,] -1 0 [2,] 1 0 [3,] 0 0 [4,] 0 0 ## among Female Male Female [1,] 0 0 [2,] 0 -1 [3,] 0 0 [4,] 0 1 ## between Male and Female Male Female [1,] -1 0 [2,] 0 0 [3,] 0 0 [4,] 0 1 JP Jin Ph.D. Bioinformatics scientist Center for Bioinformatics UNC at Chapel Hill Chapel Hill, NC [[alternative HTML version deleted]]
limma limma • 1.1k views
ADD COMMENT
0
Entering edit mode
@manca-marco-path-4295
Last seen 9.6 years ago
Dear JP I am temporarily unable to replay your example code on my workstation but it seems to me that you could simply give your contrasts to the function "lme" itself. In fact, "lme" accept an argument "contrast" that is set by default as NULL but could be changed indicating any object fitting into the category of contrast argument as defined following: contrasts.arg: A list, whose entries are values (numeric matrices or character strings naming functions) to be used as replacement values for the ?contrasts? replacement function and whose names are the names of columns of ?data? containing ?factor?s. Otherwise you could use the "contrasts.fit" function from limma instead of the "fit.contrast" (which I do not know by heart... to which package does it belong to? Maybe it is also accepting a matrix as input to the value "contrasts") which would accept a contrast.arg too: > contrasts.fit(fit, contrasts=NULL, coefficients=NULL) I'm quite not sure what do you mean for "comparison among males" though, as to me is not clear what are you supposed to use as a contrast within the variable "sex" when all the subjects have only one value and the patients' IDs have been modeled as random effects... maybe you'd rather want to subset your dataset by sex: > Data<-Orthodont[Orthodont$Sex=="Male"] and then produce a contrast matrix on some other variables (AgeGroup as instance?) ...but maybe I am going off since I haven't understood the purpose of the analysis. I hope this helps you anyway. Good luck, Marco -- Marco Manca, MD University of Maastricht Faculty of Health, Medicine and Life Sciences (FHML) Cardiovascular Research Institute (CARIM) Mailing address: PO Box 616, 6200 MD Maastricht (The Netherlands) Visiting address: Experimental Vascular Pathology group, Dept of Pathology - Room5.08, Maastricht University Medical Center, P. Debyelaan 25, 6229 HX Maastricht E-mail: m.manca at maastrichtuniversity.nl Office telephone: +31(0)433874633 Personal mobile: +31(0)626441205 Twitter: @markomanka ********************************************************************** *********************************************** This email and any files transmitted with it are confidential and solely for the use of the intended recipient. It may contain material protected by privacy or attorney-client privilege. If you are not the intended recipient or the person responsible for delivering to the intended recipient, be advised that you have received this email in error and that any use is STRICTLY PROHIBITED. If you have received this email in error please notify us by telephone on +31626441205 Dr Marco MANCA ********************************************************************** *********************************************** ________________________________________ Da: bioconductor-bounces at stat.math.ethz.ch [bioconductor-bounces at stat.math.ethz.ch] per conto di Jin, Jp [jjin at email.unc.edu] Inviato: marted? 26 ottobre 2010 15.40 A: bioconductor at stat.math.ethz.ch Oggetto: [BioC] need help on Dear statisticians of the list, I am a limma user and have a small data set that I used the lme mixed effect model for analysis. I need some help in extracting comparisons from the result. I sent my questions to the R help list, but it appears that there is no people there care about the questions. I know my questions may not be related to this list, but if you would help could you please point me out what I can do or I should do something else? Your help will be greatly appreciated. My data set is similar to the example data, Orthodont, and I used patient subject as a random effect and did something below: library(nlme) library(gregmisc) data(Orthodont) Orthodont$AgeGroup <- gtools::quantcut(Orthodont$age) fm <- lme(distance ~ AgeGroup + Sex + AgeGroup*Sex, data = Orthodont, random = ~1|Subject) fit.contrast(fm, "Sex", c(-1,1), conf=0.95) fit.contrast(fm, "AgeGroup", rbind("1 vs 2"=c(-1,1,0,0), "2 vs 3"=c(0,-1,1,0)), conf=0.95) But how can I compare different age groups among Male, Female or between Male and Female as illustrated below (age groups on rows): ## comparison among Male Male Female [1,] -1 0 [2,] 1 0 [3,] 0 0 [4,] 0 0 ## among Female Male Female [1,] 0 0 [2,] 0 -1 [3,] 0 0 [4,] 0 1 ## between Male and Female Male Female [1,] -1 0 [2,] 0 0 [3,] 0 0 [4,] 0 1 JP Jin Ph.D. Bioinformatics scientist Center for Bioinformatics UNC at Chapel Hill Chapel Hill, NC [[alternative HTML version deleted]] _______________________________________________ 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
ADD COMMENT
0
Entering edit mode
Dear Marco, Thank you very much for your quick reply! What I was trying to do was to extract the comparisons of age group 1 and group 2 in male, or group 3 vs group 4 in female, or between groups of male and female. Please see the following chart: Contrasts Levels M.8vs10 F.12vs14 M.10vsF.10 Female.y10 0 0 -1 Female.y12 0 1 0 Female.y14 0 -1 0 Female.y8 0 0 0 Male.y10 -1 0 1 Male.y12 0 0 0 Male.y14 0 0 0 Male.y8 1 0 0 I don't know how to define "contrast" in lme itself with more than one variable of interest. It is great if that works. But I tried contrasts.fit as the following and got an error message: library(nlme) data(Orthodont) AgeGroup <- factor(rep(c("y8","y10","y12","y14"),27)) Orthodont <- cbind(Orthodont[,1:4],AgeGroup) fm <- lme(distance ~ AgeGroup + Sex + AgeGroup*Sex, data = Orthodont, random = ~1|Subject) AgeGroup <- factor(rep(c("y8","y10","y12","y14"),27)) Orthodont <- cbind(Orthodont[,1:4],AgeGroup) TS <- paste(c(rep("Male",64),rep("Female",44)),c("y8","y10","y12","y14 "),sep=".") TS <- factor(TS) design <- model.matrix(~0+TS) colnames(design) <- levels(TS) cont.matrix <- makeContrasts( M.8vs10=Male.y8-Male.y10, F.12vs14=Female.y12-Female.y14, M.10vsF.10=Male.y10-Female.y10, levels=design) fm2 <- contrasts.fit(fm,cont.matrix) Error in contrasts.fit(fm, cont.matrix) : Number of rows of contrast matrix must match number of coefficients Could you please point out what is wrong? I really appreciate your time and help! JP- -----Original Message----- From: Manca Marco (PATH) [mailto:m.manca@maastrichtuniversity.nl] Sent: Tuesday, October 26, 2010 10:13 AM To: Jin, Jp; bioconductor at stat.math.ethz.ch Subject: R: [BioC] need help on Importance: Low Dear JP I am temporarily unable to replay your example code on my workstation but it seems to me that you could simply give your contrasts to the function "lme" itself. In fact, "lme" accept an argument "contrast" that is set by default as NULL but could be changed indicating any object fitting into the category of contrast argument as defined following: contrasts.arg: A list, whose entries are values (numeric matrices or character strings naming functions) to be used as replacement values for the 'contrasts' replacement function and whose names are the names of columns of 'data' containing 'factor's. Otherwise you could use the "contrasts.fit" function from limma instead of the "fit.contrast" (which I do not know by heart... to which package does it belong to? Maybe it is also accepting a matrix as input to the value "contrasts") which would accept a contrast.arg too: > contrasts.fit(fit, contrasts=NULL, coefficients=NULL) I'm quite not sure what do you mean for "comparison among males" though, as to me is not clear what are you supposed to use as a contrast within the variable "sex" when all the subjects have only one value and the patients' IDs have been modeled as random effects... maybe you'd rather want to subset your dataset by sex: > Data<-Orthodont[Orthodont$Sex=="Male"] and then produce a contrast matrix on some other variables (AgeGroup as instance?) ...but maybe I am going off since I haven't understood the purpose of the analysis. I hope this helps you anyway. Good luck, Marco -- Marco Manca, MD University of Maastricht Faculty of Health, Medicine and Life Sciences (FHML) Cardiovascular Research Institute (CARIM) Mailing address: PO Box 616, 6200 MD Maastricht (The Netherlands) Visiting address: Experimental Vascular Pathology group, Dept of Pathology - Room5.08, Maastricht University Medical Center, P. Debyelaan 25, 6229 HX Maastricht E-mail: m.manca at maastrichtuniversity.nl Office telephone: +31(0)433874633 Personal mobile: +31(0)626441205 Twitter: @markomanka ********************************************************************** *********************************************** This email and any files transmitted with it are confidential and solely for the use of the intended recipient. It may contain material protected by privacy or attorney-client privilege. If you are not the intended recipient or the person responsible for delivering to the intended recipient, be advised that you have received this email in error and that any use is STRICTLY PROHIBITED. If you have received this email in error please notify us by telephone on +31626441205 Dr Marco MANCA ********************************************************************** *********************************************** ________________________________________ Da: bioconductor-bounces at stat.math.ethz.ch [bioconductor-bounces at stat.math.ethz.ch] per conto di Jin, Jp [jjin at email.unc.edu] Inviato: marted? 26 ottobre 2010 15.40 A: bioconductor at stat.math.ethz.ch Oggetto: [BioC] need help on Dear statisticians of the list, I am a limma user and have a small data set that I used the lme mixed effect model for analysis. I need some help in extracting comparisons from the result. I sent my questions to the R help list, but it appears that there is no people there care about the questions. I know my questions may not be related to this list, but if you would help could you please point me out what I can do or I should do something else? Your help will be greatly appreciated. My data set is similar to the example data, Orthodont, and I used patient subject as a random effect and did something below: library(nlme) library(gregmisc) data(Orthodont) Orthodont$AgeGroup <- gtools::quantcut(Orthodont$age) fm <- lme(distance ~ AgeGroup + Sex + AgeGroup*Sex, data = Orthodont, random = ~1|Subject) fit.contrast(fm, "Sex", c(-1,1), conf=0.95) fit.contrast(fm, "AgeGroup", rbind("1 vs 2"=c(-1,1,0,0), "2 vs 3"=c(0,-1,1,0)), conf=0.95) But how can I compare different age groups among Male, Female or between Male and Female as illustrated below (age groups on rows): ## comparison among Male Male Female [1,] -1 0 [2,] 1 0 [3,] 0 0 [4,] 0 0 ## among Female Male Female [1,] 0 0 [2,] 0 -1 [3,] 0 0 [4,] 0 1 ## between Male and Female Male Female [1,] -1 0 [2,] 0 0 [3,] 0 0 [4,] 0 1 JP Jin Ph.D. Bioinformatics scientist Center for Bioinformatics UNC at Chapel Hill Chapel Hill, NC [[alternative HTML version deleted]] _______________________________________________ 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
ADD REPLY

Login before adding your answer.

Traffic: 860 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6