# commandArgs() # script.description <- function() # showConnections() [as.character(eval.parent(quote(file), n = 3)), # "description"] # print((basename(script.description()))) ###################################### #Inputs to enter# #################################### #variables specifying the experiment: foldername ="tubPKCixd42+-chaG80" filenameprefix ="tG80_PKCi_d42g_" firstpoint =1 datapoints <- 79 # figshare infos # create the article on the first run (if no id_test is given) # after first run, return "id", you get a number to insert as a value for the id_test # next runs will update the existing article (only the figure in this version) thisfile= "analysispkcd42.r" article_title= "Drosophila self-learning. Inhibition of PKC in d42Gal4 neurons, effect of additional UAS-GFP and cha-Gal80 constructs" article_type = "figure" #, "dataset" #,"media", "poster", "paper", "fileset" article_tags = c("self-learning","genetics", "FBti0010565","FBtp0017264","FBti0002759","FBtp0016755") article_categories="Neuroscience" article_visibility= "draft" #"private" "public" # article_authors= c("97229","96464" ) ## Julien Colomb = 97229 ## Björn Brembs = 96464 article_links="http://lab.brembs.net" ###rfigshare automatic inputs: setwd(paste("D:/dokumente/data/FSdata",foldername, sep="/")) AD= scan("experiment_description.txt", what="character") article_description = as.character(AD[1]) id_figure =id_data=id_fileset =id_code= NA alreadyuploaded=0 ids= scan("id_numbers.txt", what="character", skip=1) for (i in c(1: length(ids))){ if ("id_figure" == ids[i]){ id_figure = ids[i+1]} if ("id_data" == ids[i]){ id_data = ids[i+1]} if ("id_fileset" == ids[i]){ id_fileset = ids[i+1]} if ("id_rawdata" == ids[i]){ id_rawdata = ids[i+1]} if ("id_code" == ids[i]){ id_code = ids[i+1]} if ("alreadyuploaded" == ids[i]){ alreadyuploaded = ids[i+1]} } #fs_update(id_test, title= article_title, description = article_description, type = article_type) ###################################################################################### #start code of analysis ######################################### require(plotrix) require(MASS) require (vioplot) require (UsingR) require (gplots) require (lattice) require (gdata) setwd(paste("D:/dokumente/data/FSdata",foldername, sep="/")) #filenameprefix ="mipkc53e_" #filenameprefix ="test_" #filenameprefix ="pkcdelta_" #take 23to27 out #i <- c(firstpoint:46,48:datapoints) i <- c(firstpoint:datapoints) ###only glued by me #i <- c(40:46,74:92) bjoerndata =F #i <- c(40:datapoints) #bjoerndata =FALSE ########################## #get data with headers, selection of data has to be done on "data" for problems in samplesize calculation# ########################## # vector with filenames change i for having all files #i <- c(1:18,20:datapoints) #i <- c(1:27:29) filenames <- sapply(i,function(v) { paste(filenameprefix,v,".txt.TXT",sep="") }) rawfilenames <- sapply(i,function(v) { paste(filenameprefix,v,".txt",sep="") }) # filenames <- c("wtb_2.txt","wtb_3.txt") # read all the files #data <- lapply(filenames,function(name) { # read.table(name,header=FALSE,skip=22) #}) # acces data frames with data[[i]] dat <- lapply(filenames,function(name) { read.table(name,header=FALSE, sep ="\t", col.names= paste ("V",1:18),fill=TRUE) }) # for (j in c(1: length(i))) # dat[[j]] = dat[[j]][c(1:16,24,25)] dat data=do.call(rbind,dat) headnames <- sapply(0,function(v) { paste(filenameprefix,v,".txt.TXT", sep ="") }) head <- lapply(headnames,function(name) { read.table(name,header=TRUE, sep ="\t") }) head=do.call(rbind,head) #head = head[c(1:16,24,25)] head names(data) <- names (head) #### data_ori=data data2 = subset (data, is.na (data$remarks) ) E= 100* mean(summary(data2$date))/mean(summary(data$date)) plot(data$date, main=paste("efficacy of experiments: ",format(E, digits=2),"%"),las=2) plot(data2$date, col=2, add=TRUE, axis=FALSE) abline(h=mean(summary(data$date))) abline(h=mean(summary(data2$date)),col=2) ### data_ori=data data2 = subset (data, is.na (data$remarks) ) E= 100* mean(summary(data2$date))/mean(summary(data$date)) plot(data$date, main=paste("efficacy of experiments: ",format(E, digits=2),"%"),las=2) plot(data2$date, col=2, add=TRUE, axis=FALSE) abline(h=mean(summary(data$date))) abline(h=mean(summary(data2$date)),col=2) ### add bjoern data if (bjoerndata){ bjoerndata = read.csv ("tubPKCixc380/bjoerndata.csv", header=TRUE) #bjoerndata data= rbind(bjoerndata,data_ori) } #bjoerndata = read.csv ("PKCRNAi/bjoerndata.csv", header=TRUE) bjoerndata #data= rbind(bjoerndata,data_ori) ### subset of date data$date[data$date =="17/4/2012"] ="17/04/2012" data= subset(data, data$date !="17/04/2012") data$genotype[data$genotype =="RnaiPKC_J"]="RnaiPKC_53e" data$genotype[data$genotype =="RnaiPKC_H"]="RnaiPKC_Inac" data$genotype[data$genotype =="RnaiPKC_K"]="CSx53eRNAi" data$genotype[data$genotype =="csx53eRNAi"]="CSx53eRNAi" data= drop.levels(data) ############### #get subset of data (if additional genotypes or so... ########## #data = subset (data, data$genotype != "PKC_elav_34°") #data=drop.levels (data) # data ############# #make data readable and calculate mean before variables #data$meanbefore = (data$X1_pretest1 +data$X2_pretest2)/2 data$meanbefore = (data$X2_pretest2) data_ordtot <- cbind(data[gl(nrow(data), 1, 7*nrow(data)), c(1:7,17:18)], stack(data[, 9:15])) data_ordtot$values <- data_ordtot$values/10000 data$scorerelative = (data$X8_test2 -data$meanbefore)/10000 data$scorenotrelative = (data$X8_test2 )/10000 added = "all" source ("D:/dokumente/data/Rfiles/fs/dataanalysis3g.r") ################################################ ################################################ ################################################ ################### subset ################### ############################################## ######################## # get data subset :without remarks or meanbefore center at 5500 # data$remarks data = subset (data, is.na (data$remarks) ) data = subset (data, data$meanbefore<6000) data data$meanbefore = (data$X2_pretest2) data_ordtot <- cbind(data[gl(nrow(data), 1, 7*nrow(data)), c(1:7,17:18)], stack(data[, 9:15])) data_ordtot$values <- data_ordtot$values/10000 data$scorerelative = (data$X8_test2 -data$meanbefore)/10000 data$scorenotrelative = (data$X8_test2 )/10000 added = "subset" ## Data treatment is ready for analysis and ploting: source ("D:/dokumente/data/Rfiles/fs/dataanalysis3g.r") #produce a pdf with all the analysis locally source ("D:/dokumente/data/Rfiles/fs/dataanalysisfigshare.r") #produce a png image with the principal results and publish it in figshare data$scorenotrel = (data$X8_test2 )/10000 data$scorenotrel_asin = asin(sqrt((data$scorenotrel+1)/2)) #data$color_asin = asin(sqrt((data$X5_test1/10000 +1)/2)) #change=ddata$scorenotrel -data$Xb_test3/10000 plot(data$scorenotrel_asin~data$genotype) abline(h=asin(sqrt((0.5)))) aov = aov(data$scorenotrel_asin~data$genotype*data$side_punished) #aov2 = aov(data$color_asin~data$genotype) summary(aov) TukeyHSD(aov) aov = aov(data$scorenotrel_asin~data$genotype*data$date) summary(aov) TukeyHSD(aov) aov = aov(data$scorenotrel_asin~data$genotype) summary(aov) TukeyHSD(aov) #plot(change~data$genotype) # # K="PKC_elav" # #K="CS_elav" # #K="PKC_OK371" # datag=subset (data, data$genotype== K) # plot(datag$X8_test2~datag$date, main=K) # abline(h=0) # # K="CS_elav" # #K="PKC_OK371" # datag=subset (data, data$genotype== K) # plot(datag$X8_test2~datag$date, main=K) # abline(h=0) # # boxplot(data$X8_test2~ data$date, boxwex = 0.25,subset = data$genotype== K, at= 1: length(levels(data$date)) -0.2, col="yellow") # boxplot(data$X8_test2~ data$date, boxwex = 0.25,subset = data$genotype== "PKC_elav", at= 1: length(levels(data$date)) +0.2, col="orange", add=TRUE) # legend("topleft", c(K, "PKC_elav"), # fill = c("yellow", "orange")) # abline(h=0) dev.off() ### data_orig= data data= subset(data_orig,data_orig$side_punished == "positive-left") added = "_left" data_ordtot <- cbind(data[gl(nrow(data), 1, 7*nrow(data)), c(1:7,17:18)], stack(data[, 9:15])) data_ordtot$values <- data_ordtot$values/10000 source ("D:/dokumente/data/Rfiles/fs/dataanalysisoneside.r") #dev.off() data= subset(data_orig,data_orig$side_punished == "negative_right") added = "_right" data_ordtot <- cbind(data[gl(nrow(data), 1, 7*nrow(data)), c(1:7,17:18)], stack(data[, 9:15])) data_ordtot$values <- data_ordtot$values/10000 source ("D:/dokumente/data/Rfiles/fs/dataanalysisoneside.r") #dev.off() data$date=as.Date(data$date, "%d/%m/%y") p =ggplot(data, aes (date,scorenotrelative)) p + geom_point(aes(colour=factor(genotype)),size = 5) p + geom_boxplot(aes(fill=factor(genotype))) # ############################################################################################################################# # ############################################################################################################################# # ########### on Figshare # ##### # # ## you need to install Rtools first (the version which correspond to your R version) # ## install devtools package then, rjson package # # you need to set figshare to receive R commands: https://github.com/ropensci/rfigshare # # ## Julien Colomb = 97229 # ## Björn Brembs = 96464? # # ###start installing packages # # # # colomb account # options(FigshareKey = "jBkrLNsYbeov2oM09cXBBw") # options(FigsharePrivateKey = "LhQkDeJaVJzAhWRIKYeobA") # options(FigshareToken = "BYuYn4OjWjd8njBKCyeFXQOEAYY1MfLJ1Y0z80rVWj6AXYuYn4OjWjd8njXKCyeFXQ") # options(FigsharePrivateToken = "aC2q4lBod3Xl52CeKwp7Fg") # ###end figshare info # #brembs lab account # options(FigshareKey = "ABqLKahr9d8EBuBCdBBxpg") # options(FigsharePrivateKey = "OCehduRnbLFvQBtD4KAZBA") # options(FigshareToken = "Jr4eYBQkgEuOvJ5PdAlXpQ851uziewWIa5M3EgqpySAQJr4eYXQkgEuOvJ5PdAlXpQ") # options(FigsharePrivateToken = "0WX9Lz0bWN5TA3fP0xnAXA") # ###end figshare info # # # # require(rfigshare) # fs_auth() # # ##need to create the article and get its id here: do it only once, then write the id and comment this part: # # if (firstrun){ # article_title= "d42Gal4 UPKCi experiment: with and without UASGFP and chaGal80" # article_description = "this is a temporary article" # article_type = "figure" #, "dataset" #,"media", "poster", "paper", "fileset" # article_tags = c("self-learning","genetics") # article_categories="Neuroscience" # article_files = paste(filenameprefix,"subset",".pdf",sep="") # article_visibility= "draft" #"private" "public" # # article_authors= c("julien colomb") # article_links="http://lab.brembs.net" # # # id <- fs_new_article(title = article_title, description = article_description, # type = article_type, tags = article_tags, categories=article_categories , # files = article_files, visibility= article_visibility, #authors = article_authors, # links=article_links) # ##add bjoern as author: # rfigshare:::fs_add_author(article_id = id_test, author_id = 96464) # # id # } # #### uncomment this part to upgrade the graph (need to write the id of course): # # id_test =97877 # # newfile= paste(filenameprefix,"subset",".pdf",sep="") # fs_upload(id_test, file =newfile) # # # # fs_update