##############################################################
# #
# A Script for the Analysis of: #
# Echinacea pallida and Echinacea angustifolia #
# reciprical crosses performed during the summer of 2011 #
# #
##############################################################
# #
# @Author: Nicholas Goldsmith #
# @Professor: Stuart Wagenius #
# @Collaborators: #
# @Date 27 July 2011 #
# #
##############################################################
# #
# Table of Contents: #
# 1) Importing the Data #
# 1.5) The Data #
# 2) Quick Check of the Data #
# 3) Quick Data Summary #
# 4) Histograms #
# 5) Plot of the Data #
# 6) Chi Squared E. pallida paternal's significance #
# 7) Chi Squared E. pallida maternal's significance #
# #
##############################################################
# 1) Importing the Data
crossData <- read.csv("http://blog.lib.umn.edu/wage0005/echinacea/CSV_recip_Crosses.csv")
# 1.5) The Data
#crossData$Pallida = E. pallida ID (Ex. PAL1001)
#crossData$Angustifolia = E. angustifolia ID (Ex. 18_967)
#crossData$PalColor = color the bracts on E. pallida was painted (Ex. AQA)
#crossData$PalColorDate = Date the E. pallida bracts were painted
#crossData$PalNumBract = Number of E. pallida bracts painted
#crossData$PalDateCross = Date the E. pallida was pollinated
#crossData$PalnumCross = Number of styles pollinated
#crossData$PalNumShrivel = Number of E. pallida styles that shriveled
#crossData$PalPercentShrivel = Percentage of E. pallida styles that shriveled
#crossData$PalComp = Compatability of the cross with E. pallida as the maternal plant with: 0 = incompatible, 1 = compatible, 99 = unsure
#crossData$AngColor = color the bracts on E. angustifolia was painted (Ex. AQA)
#crossData$AngColorDate = Date the E. angustifolia bracts were painted
#crossData$AngNumBract = Number of E. angustifolia bracts painted
#crossData$AngDateCross = Date the E. angustifolia was pollinated
#crossData$AngnumCross = Number of styles pollinated
#crossData$AngNumShrivel = Number of E. angustifolia styles that shriveled
#crossData$AngPercentShrivel = Percentage of E. angustifolia styles that shriveled
#crossData$AngComp = Compatability of the cross with E. angustifolia as the maternal plant with: 0 = incompatible, 1 = compatible, 99 = unsure
# 2) Quick Check of the Data
str(crossData)
levels (crossData$Pallida) #Checking the entries for the E. pallida plants
#I noticed that Excel has added in an row under my data, and have removed it
levels (crossData$Angustifolia) #Checking the entries for the E. angustifolia plants
#All of these look fine
# 3) Quick Data Summary
summary(crossData$PalPercentShrivel) #Getting a summary of the E. pallida style shriveling
summary(crossData$AngPercentShrivel) #Now for the E. angustifolia summary
#Mean is higher for E. angustifolia, therefore more shriveling probably occurred
table(crossData$PalPercentShrivel) #Gives a table summary of the maternal E. pallida data
table(crossData$AngPercentShrivel) #Gives a table summary of the maternal E. angustifolia data
# 4) Histograms
#hist(crossData$PalPercentShrivel, breaks=seq(0,100,by=((100)*(1/30)))) #Historgram of the E. pallida style shriveling with breaks for each style's percentage
#abline(v=25, col="red") #Puts in a line at 25%, the cut off for considering incompatible
#abline(v=75, col="red") #Puts in a line at 75%, the cut off for considering compatible
windows() #Makes a window for the first histogram
hist(crossData$PalPercentShrivel, breaks=seq(0,100,by=((100)*(1/3)))) #Histogram when E. pallida is the maternal plant
windows() #Makes a window for the second historgram
hist(crossData$AngPercentShrivel, breaks=seq(0,100,by=((100)*(1/3)))) #Histogram when E. angustolia is the maternal plant
# 5) Plot of the Data
#Comparing the E. pallida and E. angustifolia shriveling data
#This is kind of a silly plot, it pretty much just shows that when E. pallida or E. angustifolia have a certain percent shriveling, we saw the other exhibit certain percentages
windows() #Makes a window for this plot
plot(crossData$PalPercentShrivel, crossData$AngPercentShrivel) #Plots the data
#Just a thought, but can I predict if one is compatible if the other will be?
# 6) Chi Squared E. pallida paternal's significance
#I want to see if particular E. pallida plants tend to be more/less compatible than others
#Could I do a Chi-squared test with the null that all cause the same shriveling (the mean)?
#Then if E. pallida plant is significant, that provides some evidence that certain S Alleles overlap, right?
#***This Chi Squared Test looks at the shriveling percentage
table(crossData$Pallida,crossData$AngPercentShrivel)
chisq.test(table(crossData$Pallida,crossData$AngPercentShrivel))
#I should make my compatability data a bit more categorical than percents
#Have be 0 be incompatible, 1 be compatible, and 99 be unsure
#***This Chi Squared Test looks at the shriveling as 3 categories
table(crossData$Pallida,crossData$AngComp)
chisq.test(table(crossData$Pallida,crossData$AngComp))
#***This Chi Squared looks at the shriveling as 2 categories, removing unsure
crossSubset <- subset(crossData, AngComp != 99)
table(crossSubset$Pallida,crossSubset$AngComp)
chisq.test(table(crossSubset$Pallida,crossSubset$AngComp))
#Need to check on changing the Expected for these?
# 7) Chi Squared E. pallida maternal's significance
#***This Chi Squared Test looks at the shriveling percentage
table(crossData$Pallida,crossData$PalPercentShrivel)
chisq.test(table(crossData$Pallida,crossData$PalPercentShrivel))
#***This Chi Squared Test looks at the shriveling as 3 categories
table(crossData$Pallida,crossData$PalComp)
chisq.test(table(crossData$Pallida,crossData$AngComp))
#***This Chi Squared looks at the shriveling as 2 categories, removing unsure
crossSubset <- subset(crossData, PalComp != 99)
table(crossSubset$Pallida,crossSubset$PalComp)
chisq.test(table(crossSubset$Pallida,crossSubset$PalComp))
#Checking the Expected values used in the Chi Squared Test
chiTestResult7 <- chisq.test(table(crossSubset$Pallida,crossSubset$PalComp))
chiTestResult7$expected
# 8) Is maternal E. pallida more/less likely to be compatible?
# 9) Is paternal E. pallida more/less likely to be compatible?