Skip to content
Snippets Groups Projects
Commit 8ffae7f7 authored by Sterken, Mark's avatar Sterken, Mark
Browse files

Data wrangling Nema

parents
Branches
No related tags found
No related merge requests found
Showing
with 569 additions and 0 deletions
.Rproj.user
.Rhistory
.RData
.Ruserdata
################################################################################
### R-script for R-meeting 10/09/2015 ##########################################
################################################################################
###If you use Tinn-R, use this to be able to send multiple lines of code
.trPaths <- paste(paste(Sys.getenv('APPDATA'), '\\Tinn-R\\tmp\\', sep=''),c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r','lines.r'), sep='')
###Set your work directory
setwd("E:/20150910")
workwd <- getwd()
###Load & install packages
#install.packages("colorspace")
library("colorspace")
#install.packages("ggplot2");
library("ggplot2") ###http://ggplot2.org/
#install.packages("dplyr");
library("dplyr")
#install.packages("tidyr");
library("tidyr")
#install.packages("RColorBrewer")
library("RColorBrewer")
#source("http://www.bioconductor.org/biocLite.R") ; biocLite("limma") ; biocLite("statmod")
library(limma)
#install.packages("gridExtra")
library(gridExtra)
#install.packages("VennDiagram")
library("VennDiagram")
###Set plotting theme
presentation <- theme(axis.text.x = element_text(size=16, face="bold", color="black"),
axis.text.y = element_text(size=16, face="bold", color="black"),
axis.title.x = element_text(size=20, face="bold", color="black"),
axis.title.y = element_text(size=20, face="bold", color="black"),
strip.text.x = element_text(size=20, face="bold", color="black"),
strip.text.y = element_text(size=20, face="bold", color="black"),
plot.title = element_text(size=24, face="bold"),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
legend.position = "right",
plot.margin = unit(c(2, 2, 2, 2), "inch"))
blank_theme <- theme(plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
plot.margin = unit(c(2, 2, 2, 2), "cm"))
################################################################################
### Load data ##################################################################
################################################################################
Data.Paula <- read.delim("Data_Paula.txt"); head(Data.Paula); colnames(Data.Paula)
colnames(Data.Paula)[38:65] <- paste("LN_",colnames(Data.Paula)[10:37],sep="")
Data.Paula.list <- select(Data.Paula,-c(LN_All.bacteria:LN_Pris)) %>%
gather(key=Measurement,value=Number,-c(Sampleid:OM)) %>%
mutate(Number = as.numeric(as.character(unlist(Number))), Number_LN=log(as.numeric(as.character(unlist(Number))))+0.1)
Data.Paula.list[Data.Paula.list == -Inf] <- 0
This diff is collapsed.
File added
File added
###Load & install packages
install.packages("colorspace")
install.packages("ggplot2")
install.packages("dplyr")
install.packages("tidyr")
install.packages("RColorBrewer")
install.packages("gridExtra")
install.packages("VennDiagram")
###load
library("colorspace")
library("ggplot2") ###http://ggplot2.org/
library("dplyr")
library("tidyr")
library("RColorBrewer")
library(gridExtra)
library("VennDiagram")
###Set plotting theme
presentation <- theme(axis.text.x = element_text(size=16, face="bold", color="black"),
axis.text.y = element_text(size=16, face="bold", color="black"),
axis.title.x = element_text(size=20, face="bold", color="black"),
axis.title.y = element_text(size=20, face="bold", color="black"),
strip.text.x = element_text(size=20, face="bold", color="black"),
strip.text.y = element_text(size=20, face="bold", color="black"),
plot.title = element_text(size=24, face="bold"),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
legend.position = "right")
blank_theme <- theme(plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank())
####Set a work directory
workwd <- "E:/PhD Nema/Data_wrangling/20160119"
setwd(workwd)
####Look what is in the directory
dir()
###Load the .txt file
wormdim <- read.delim(file=dir()[grep(".txt",dir())])
###Inspect the file
head(wormdim)
###gather()
wormdim.long <- gather(wormdim,key=trait,value=measurement,-c(Line:Remarks))
output <- filter(wormdim, Length.nematode>1300, Length.nematode<1400,Stage=="L4") %>%
select(-c(Width.at.vulva:Length.procorpus))%>%
arrange(-Length.nematode) %>%
mutate(Ratio=Width_pharynx/Length.nematode,Ratio_t=Length.nematode/Temp)
output2 <- filter(wormdim, !is.na(Length.nematode), !is.na(Width_pharynx)) %>%
group_by(Temp,Stage) %>%
summarise(cor.nu=cor(Length.nematode,Width_pharynx),n=length(Width_pharynx))
ggplot(wormdim,aes(x=Length.nematode,y=Width_pharynx,colour=Temp)) +
geom_point() + facet_grid(Stage~Temp)
###filter()
###select()
###arrange()
###mutate()
###summarise()
This diff is collapsed.
####Set a work directory
workwd <- "E:/PhD Nema/Data_wrangling/20160119"
setwd(workwd)
####Look what is in the directory
dir()
###Load the .txt file
wormdim <- read.delim(file=dir()[grep(".txt",dir())])
###Inspect the file
head(wormdim)
###gather()
wormdim.long <- gather(wormdim,key=trait,value=measurement,-c(Line:Remarks))
output <- filter(wormdim, Length.nematode>1300, Length.nematode<1400,Stage=="L4") %>%
select(-c(Width.at.vulva:Length.procorpus))%>%
arrange(-Length.nematode) %>%
mutate(Ratio=Width_pharynx/Length.nematode,Ratio_t=Length.nematode/Temp)
output2 <- filter(wormdim, !is.na(Length.nematode), !is.na(Width_pharynx)) %>%
group_by(Temp,Stage) %>%
summarise(cor.nu=cor(Length.nematode,Width_pharynx),n=length(Width_pharynx))
ggplot(wormdim,aes(x=Length.nematode,y=Width_pharynx,colour=Temp)) +
geom_point() + facet_grid(Stage~Temp)
###filter()
###select()
###arrange()
###mutate()
###summarise()
###Load & install packages
install.packages("colorspace")
install.packages("ggplot2")
install.packages("dplyr")
install.packages("tidyr")
install.packages("RColorBrewer")
install.packages("gridExtra")
install.packages("VennDiagram")
###load
library("colorspace")
library("ggplot2") ###http://ggplot2.org/
library("dplyr")
library("tidyr")
library("RColorBrewer")
library(gridExtra)
library("VennDiagram")
###Set plotting theme
presentation <- theme(axis.text.x = element_text(size=16, face="bold", color="black"),
axis.text.y = element_text(size=16, face="bold", color="black"),
axis.title.x = element_text(size=20, face="bold", color="black"),
axis.title.y = element_text(size=20, face="bold", color="black"),
strip.text.x = element_text(size=20, face="bold", color="black"),
strip.text.y = element_text(size=20, face="bold", color="black"),
plot.title = element_text(size=24, face="bold"),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
legend.position = "right")
blank_theme <- theme(plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank())
File added
This diff is collapsed.
####Set a work directory
workwd <- "I:/PhD Nema/Data_wrangling/20160302"
setwd(workwd)
####Load packages
source("Loader_DataWrangling.r") ####This means this script is in the same folder als de workdirectory you just set!!!!
###Load the .txt file (data from Sonja)
cysts <- read.delim(file="ScreeningA.txt"); head(cysts)
###Is the eggmass normaly distributed?
###Are the plants with size G (Groot - large) different from the others?
###What would be a good way of presenting the data?
###gather()
###filter()
###select()
###arrange()
###mutate()
###summarise()
###Load & install packages
install.packages("colorspace")
install.packages("ggplot2")
install.packages("dplyr")
install.packages("tidyr")
install.packages("RColorBrewer")
install.packages("gridExtra")
install.packages("VennDiagram")
###load
library("colorspace")
library("ggplot2") ###http://ggplot2.org/
library("dplyr")
library("tidyr")
library("RColorBrewer")
library(gridExtra)
library("VennDiagram")
###Set plotting theme
presentation <- theme(axis.text.x = element_text(size=16, face="bold", color="black"),
axis.text.y = element_text(size=16, face="bold", color="black"),
axis.title.x = element_text(size=20, face="bold", color="black"),
axis.title.y = element_text(size=20, face="bold", color="black"),
strip.text.x = element_text(size=20, face="bold", color="black"),
strip.text.y = element_text(size=20, face="bold", color="black"),
plot.title = element_text(size=24, face="bold"),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
legend.position = "right")
blank_theme <- theme(plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank())
#####
setwd("/Users/sonja/documents/lab work/R")
source("data wrangling/Loader_DataWrangling.r") ### hoeft maar 1 keer gedaan te worden
setwd("/Users/sonja/documents/lab work/R/data wrangling")
workwd<-getwd()
setwd(workwd)
getwd()
##### inladen#####
ScreeningA<-read.delim(file ="ScreeningA.txt", header=T, sep= "\t")
head(ScreeningA)
dim(ScreeningA)
######plot data##### zie hoe het verdeeld is en hoe de uitschieters er bij zitten
ggplot(ScreeningA, aes(x=Eggmass, fill=Size_Plant)) +
geom_histogram(binwidth=1)+ facet_grid(Line~Screening)
ggplot(ScreeningA, aes(x=Line,y=Eggmass, colour=Size_Plant)) +
geom_boxplot() + geom_jitter()
ggplot(ScreeningA, aes(x=Line,y=Eggmass, colour=Size_Plant)) +
geom_jitter(width=0.5)
ggplot(ScreeningA, aes(x=Eggmass)) +
geom_bar(aes(fill=Screening))
ggplot(ScreeningA, aes(x=Line,y=Eggmass, )) +
geom_boxplot()+ geom_jitter(aes(colour=Size_Plant))+facet_grid(~Screening)
####data zonder grootte wortels###
ScreeningAN<-filter(ScreeningA, Size_Plant=="N")
ggplot(ScreeningAN, aes(x=Line,y=Eggmass, )) +
geom_boxplot()+ geom_jitter(aes(colour=Size_Plant))+facet_grid(~Screening)
ggplot(ScreeningAN, aes(x=Line,y=Eggmass, )) +
geom_boxplot()+ geom_jitter()+facet_grid(~Screening)
geom_point()+ facet_grid(Line~Eggmass)
####Bepalen of het normaal verdeeld is #####omslachtig######
Col<-filter(ScreeningA, Line=="Col")
T5<-filter(ScreeningA, Line=="T5")
T51<-filter(ScreeningA, Line=="T51")
ggplot(T51, aes(x=Eggmass)) + geom_histogram(binwidth=1)
ggplot(T5, aes(x=Eggmass)) + geom_histogram(binwidth=1)
ggplot(Col, aes(x=Eggmass)) + geom_histogram(binwidth=1)
ColN<-filter(ScreeningA, Line=="Col", Size_Plant=="N")
T51N<-filter(ScreeningA, Line=="T51", Size_Plant=="N")
T5N<-filter(ScreeningA, Line=="T5", Size_Plant=="N")
#### T.test####
####all samples
t.test(Col$Eggmass,T51$Eggmass)
t.test(Col$Eggmass, T5$Eggmass)
######removed large roots
t.test(ColN$Eggmass,T51N$Eggmass)
t.test(ColN$Eggmass, T5N$Eggmass)
##Anova###
head(ScreeningA)
anova(lm(Eggmass~Line+Screening, data=ScreeningAN)) ####where is the variation##
summary(lm(Eggmass~factor(Line,levels=c("T51","Col", "T5"))+Screening, data=ScreeningAN))####specific test####
group_by(ScreeningAN, Line,Screening)%>%
summarise(median=median(Eggmass))
Line Plant Screening Eggmass Size_Plant Col 1 1 14 N Col 2 1 11 N Col 3 1 9 N Col 4 1 10 N Col 5 1 13 N Col 6 1 12 N Col 7 1 7 N Col 8 1 10 N Col 9 1 7 N Col 10 1 16 N Col 11 1 9 N Col 12 1 4 N Col 13 1 14 N Col 14 1 8 N Col 15 1 7 N Col 16 1 9 N Col 17 1 16 N Col 18 1 11 N Col 19 1 12 N Col 20 1 25 G Col 21 1 9 N Col 22 1 4 N Col 23 1 13 N Col 24 1 7 N Col 25 2 21 G Col 26 2 10 N Col 27 2 5 N Col 28 2 35 G Col 29 2 25 G Col 30 2 6 N Col 31 2 4 N Col 32 2 8 N Col 33 2 11 N Col 34 2 24 N Col 35 2 5 N Col 36 2 3 N Col 37 2 5 N Col 38 2 4 N Col 39 2 8 N Col 40 2 9 N Col 41 2 10 N Col 42 2 5 N Col 43 2 11 N Col 44 2 17 N Col 45 2 8 N Col 46 2 16 N Col 47 2 12 N Col 48 2 6 N Col 49 3 8 N Col 50 3 11 N Col 51 3 11 N Col 52 3 15 N Col 53 3 12 N Col 54 3 13 N Col 55 3 15 N Col 56 3 12 N Col 57 3 10 N Col 58 3 15 N Col 59 3 16 N Col 60 3 18 N Col 61 3 3 N Col 62 3 13 N Col 63 3 9 N Col 64 3 11 N Col 65 3 16 G Col 66 3 6 N Col 67 3 17 N Col 68 3 10 N Col 69 3 12 N Col 70 3 19 N T5 71 1 8 N T5 72 1 6 N T5 73 1 4 N T5 74 1 4 N T5 75 1 16 N T5 76 1 5 N T5 77 1 11 N T5 78 1 4 N T5 79 1 9 N T5 80 1 8 N T5 81 1 6 N T5 82 1 7 N T5 83 1 2 N T5 84 1 2 N T5 85 1 1 N T5 86 1 4 N T5 87 1 7 N T5 88 1 3 N T5 89 2 22 N T5 90 2 25 N T5 91 2 31 G T5 92 2 11 N T5 93 2 18 N T5 94 2 38 G T5 95 2 9 N T5 96 2 3 N T5 97 2 7 N T5 98 2 2 N T5 99 2 20 G T5 100 2 21 G T5 101 2 17 N T5 102 2 19 N T5 103 2 9 N T5 104 2 7 N T5 105 2 10 N T5 106 2 27 G T5 107 2 20 N T5 108 2 3 N T5 109 2 5 N T5 110 2 8 N T5 111 2 8 N T5 112 2 9 N T5 113 3 26 G T5 114 3 12 N T5 115 3 3 N T5 116 3 11 N T5 117 3 11 N T5 118 3 10 N T5 119 3 12 N T5 120 3 18 G T5 121 3 15 N T5 122 3 12 N T5 123 3 6 N T5 124 3 15 N T5 125 3 3 N T5 126 3 10 N T5 127 3 9 N T5 128 3 13 N T5 129 3 6 N T51 130 1 25 G T51 131 1 15 N T51 132 1 9 N T51 133 1 16 N T51 134 1 9 N T51 135 1 11 N T51 136 1 8 N T51 137 1 12 N T51 138 1 16 N T51 139 1 14 N T51 140 1 9 N T51 141 1 25 G T51 142 1 14 N T51 143 1 24 G T51 144 1 21 N T51 145 1 19 N T51 146 1 35 G T51 147 1 11 N T51 148 2 22 G T51 149 2 13 N T51 150 2 12 G T51 151 2 24 G T51 152 2 40 G T51 153 2 20 N T51 154 2 10 N T51 155 2 23 N T51 156 2 15 N T51 157 2 24 N T51 158 2 18 N T51 159 2 21 N T51 160 2 5 N T51 161 2 7 N T51 162 2 11 N T51 163 2 19 N T51 164 2 26 G T51 165 2 7 N T51 166 2 8 N T51 167 2 5 N T51 168 2 10 N T51 169 2 18 N T51 170 2 8 N T51 171 2 9 N T51 172 3 7 N T51 173 3 7 N T51 174 3 7 N T51 175 3 9 N T51 176 3 11 N T51 177 3 7 N T51 178 3 15 N T51 179 3 17 N T51 180 3 12 N T51 181 3 12 N T51 182 3 7 N T51 183 3 25 G T51 184 3 20 G T51 185 3 8 N T51 186 3 8 N T51 187 3 16 N T51 188 3 15 N T51 189 3 15 N T51 190 3 8 N
\ No newline at end of file
####Set a work directory
workwd <- "I:/PhD Nema/Data_wrangling/20160414"
setwd(workwd)
####Load packages
source("Loader_DataWrangling.r") ####This means this script is in the same folder als de workdirectory you just set!!!!
###Load the .txt file (data from Sonja)
larvae <- read.delim(file="Amalia_mutants_201511.txt"); head(larvae)
###Clean up some imperfections
ggplot(larvae,aes(x=Line,y=J4s)) + geom_jitter(width=0.25,height=0) + geom_boxplot()
###Is there significant increase/reduction of the amount of nematodes in the roots compared to Col-0 (wild type)?
###Are any of these variations in the amount of nematodes related to the size of the roots of the plants?
###gather()
###filter()
###select()
###arrange()
###mutate()
###summarise()
Line J3s J4s root size Comments
col-0 3 0
col-0 3 0 big
col-0 5 0 small
col-0 4 0
col-0 5 4 med
col-0 2 0 med
col-0 7 8 big
col-0 3 0 med
col-0 3 6 big
col-0 5 7 big
col-0 4 1 small
col-0 2 0 small
geno-1 3 0
geno-1 3 3
geno-1 5 0 med
geno-1 0 3 med
geno-1 2 2 med
geno-1 2 1 small
geno-1 2 2 small
geno-1 3 2 small
geno-1 1 3
geno-2 1 1 med
geno-2 3 1 med
geno-2 1 0 small
geno-2 5 5 big
geno-2 10 2 big
geno-2 0 0 small
geno-2 2 2 med
geno-2 2 2
geno-2 1 1 med
geno-2 2 4 med
geno-2 1 1 small
geno-2 3 0 med
geno-3 1 0 small
geno-3 4 3 big
geno-3 1 0 small
geno-3 5 1 med
geno-3 4 0 med
geno-3 1 1 med
geno-3 3 3 med
geno-3 1 2 small
geno-3 5 2 med
geno-3 2 1 small
geno-4 0 1 big
geno-4 2 12 big
geno-4 3 7 big
geno-4 3 6 big
geno-4 0 1 big
geno-15 2 0 small
geno-15 1 1 small
geno-15 3 6 big
geno-15 0 2 small
geno-15 2 1 med
geno-15 6 3 med
geno-15 0 0 small
geno-15 0 5 big CONTAMINATED
geno-15 0 0 small
geno-15 0 1 small
geno-16 1 2 small
geno-16 1 0 small
geno-16 0 1 small
geno-16 2 0 small
geno-16 0 1 small
geno-16 0 4 small
geno-16 2 1 small
geno-16 0 3 med
geno-16 3 5 small
geno-17 0 1 med
geno-17 5 3 med
geno-17 3 1 med
geno-17 3 12 big
geno-17 3 2 small
geno-18 0 0 med
geno-18 1 2 big
geno-18 4 0 small
geno-18 2 3 big
geno-18 4 1 med
geno-18 3 1 med
geno-18 5 3 big
geno-18 3 5 big
geno-18 3 3 big
geno-18 0 2 med
geno-18 0 1
###Load & install packages
install.packages("colorspace")
install.packages("ggplot2")
install.packages("dplyr")
install.packages("tidyr")
install.packages("RColorBrewer")
install.packages("gridExtra")
install.packages("VennDiagram")
###load
library("colorspace")
library("ggplot2") ###http://ggplot2.org/
library("dplyr")
library("tidyr")
library("RColorBrewer")
library(gridExtra)
library("VennDiagram")
###Set plotting theme
presentation <- theme(axis.text.x = element_text(size=16, face="bold", color="black"),
axis.text.y = element_text(size=16, face="bold", color="black"),
axis.title.x = element_text(size=20, face="bold", color="black"),
axis.title.y = element_text(size=20, face="bold", color="black"),
strip.text.x = element_text(size=20, face="bold", color="black"),
strip.text.y = element_text(size=20, face="bold", color="black"),
plot.title = element_text(size=24, face="bold"),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
legend.position = "right")
blank_theme <- theme(plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank())
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment