Browse code

cleaned up fit.lm3

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/crlmm@52822 bc3139a8-67e5-0310-9ffc-ced21a209358

Rob Scharp authored on 16/02/2011 15:57:31
Showing1 changed files

... ...
@@ -776,7 +776,7 @@ fit.lm3 <- function(strata,
776 776
 		madB.Mlist <- res[["madB"]]
777 777
 		medianA.Mlist <- res[["medianA"]]
778 778
 		medianB.Mlist <- res[["medianB"]]
779
-		NN.Mlist <- res[["NN.M"]]
779
+		NN.Mlist <- res[["NN"]]
780 780
 		rm(res)
781 781
 		## Need N, median, mad
782 782
 	}
... ...
@@ -791,26 +791,17 @@ fit.lm3 <- function(strata,
791 791
 						 is.lds=is.lds,
792 792
 						 DF.PRIOR=DF.PRIOR/2,
793 793
 					   gender="female")
794
-		N.AA.F <- as.matrix(N.AA(object)[marker.index, ])
795
-		N.AB.F <- as.matrix(N.AB(object)[marker.index, ])
796
-		N.BB.F <- as.matrix(N.BB(object)[marker.index, ])
797
-		medianA.AA <- as.matrix(medianA.AA(object)[marker.index,])
798
-		medianA.AB <- as.matrix(medianA.AB(object)[marker.index,])
799
-		medianA.BB <- as.matrix(medianA.BB(object)[marker.index,])
800
-		medianB.AA <- as.matrix(medianB.AA(object)[marker.index,])
801
-		medianB.AB <- as.matrix(medianB.AB(object)[marker.index,])
802
-		medianB.BB <- as.matrix(medianB.BB(object)[marker.index,])
803
-		madA.AA <- as.matrix(madA.AA(object)[marker.index,])
804
-		madA.AB <- as.matrix(madA.AB(object)[marker.index,])
805
-		madA.BB <- as.matrix(madA.BB(object)[marker.index,])
806
-		madB.AA <- as.matrix(madB.AA(object)[marker.index,])
807
-		madB.AB <- as.matrix(madB.AB(object)[marker.index,])
808
-		madB.BB <- as.matrix(madB.BB(object)[marker.index,])
794
+		madA.Flist <- res[["madA"]]
795
+		madB.Flist <- res[["madB"]]
796
+		medianA.Flist <- res[["medianA"]]
797
+		medianB.Flist <- res[["medianB"]]
798
+		NN.Flist <- res[["NN"]]
799
+		rm(res)
809 800
 	}
810 801
 	for(k in seq_along(batches)){
811
-		B <- batches[[k]]
812
-		this.batch <- unique(as.character(batch(object)[B]))
813
-		gender <- object$gender[B]
802
+		sample.index <- batches[[k]]
803
+		this.batch <- unique(as.character(batch(object)[sample.index]))
804
+		gender <- object$gender[sample.index]
814 805
 		enough.men <- sum(gender==1) >= MIN.SAMPLES
815 806
 		enough.women <- sum(gender==2) >= MIN.SAMPLES
816 807
 		if(!enough.men & !enough.women) {
... ...
@@ -818,11 +809,11 @@ fit.lm3 <- function(strata,
818 809
 			next()
819 810
 		}
820 811
 		if(enough.women){
821
-			medianA.F <- cbind(medianA.AA[, k], medianA.AB[, k], medianA.BB[, k])
822
-			medianB.F <- cbind(medianB.AA[, k], medianB.AB[, k], medianB.BB[, k])
823
-			madA.F <- cbind(madA.AA[, k], madA.AB[, k], madA.BB[, k])
824
-			madB.F <- cbind(madB.AA[, k], madB.AB[, k], madB.BB[, k])
825
-			NN.F <- cbind(N.AA.F[, k], N.AB.F[, k], N.BB.F[, k])
812
+			madA.F <- madA.Flist[[k]]
813
+			madB.F <- madB.Flist[[k]]
814
+			medianA.F <- medianA.Flist[[k]]
815
+			medianB.F <- medianB.Flist[[k]]
816
+			NN.F <- NN.Flist[[k]]
826 817
 		}
827 818
 		if(enough.men){
828 819
 			madA.M <- madA.Mlist[[k]]
... ...
@@ -832,18 +823,18 @@ fit.lm3 <- function(strata,
832 823
 			NN.M <- NN.Mlist[[k]]
833 824
 		}
834 825
 		if(enough.men & enough.women){
835
-			betas <- fit.wls(cbind(NN.M[, c(1,3)], NN.F),
836
-					 sigma=cbind(madA.M[, c(1,3)], madA.F),
826
+			betas <- fit.wls(cbind(NN.M, NN.F),
827
+					 sigma=cbind(madA.M, madA.F),
837 828
 					 allele="A",
838
-					 Y=cbind(medianA.M[, c(1,3)], medianA.F),
829
+					 Y=cbind(medianA.M, medianA.F),
839 830
 					 autosome=FALSE)
840 831
 			nuA[, k] <- betas[1, ]
841 832
 			phiA[, k] <- betas[2, ]
842 833
 			phiA2[, k] <- betas[3, ]
843
-			betas <- fit.wls(cbind(NN.M[, c(1,3)], NN.F),
844
-					 sigma=cbind(madB.M[, c(1,3)], madB.F),
834
+			betas <- fit.wls(cbind(NN.M, NN.F),
835
+					 sigma=cbind(madB.M, madB.F),
845 836
 					 allele="B",
846
-					 Y=cbind(medianB.M[, c(1,3)], medianB.F),
837
+					 Y=cbind(medianB.M, medianB.F),
847 838
 					 autosome=FALSE)
848 839
 			nuB[, k] <- betas[1, ]
849 840
 			phiB[, k] <- betas[2, ]