data("genotypebyage")
####An analysis by genotype
#Create a freqMAP object for probands and controls, respectively.
fm.cont <- freqMAP(genotypebyage[genotypebyage$subject.type=="control",c("age","genotype")],
x=seq(25,95,by=5),x.label="age",hw=5)
fm.prob <- freqMAP(genotypebyage[genotypebyage$subject.type=="proband",c("age","genotype")],
x=seq(25,95,by=5),x.label="age",hw=5)
#Plot the two MAPs overlaid.
plot(fm.cont,fm.prob,legend=c("controls","probands"),show.p.value.legend=TRUE)
####An analysis by allele
#Reformat the dataset to stack the two alleles into one column. The
#resulting dataset has twice as many rows as genotypebyage
allelebyage <- rbind(cbind(genotypebyage[,c("age","subject.type")],
allele=genotypebyage$allele1,stringsAsFactors=FALSE),
cbind(genotypebyage[,c("age","subject.type")],
allele=genotypebyage$allele2,stringsAsFactors=FALSE))
#Create a freqMAP object for probands and controls, respectively.
fm.cont <- freqMAP(allelebyage[allelebyage$subject.type=="control",c("age","allele")],
x=seq(25,95,by=5),x.label="age",hw=5)
fm.prob <- freqMAP(allelebyage[allelebyage$subject.type=="proband",c("age","allele")],
x=seq(25,95,by=5),x.label="age",hw=5)
plot(fm.cont,fm.prob,legend=c("controls","probands"),show.p.value.legend=TRUE)
Run the code above in your browser using DataLab