Commit 17830484 authored by Antonio Politi's avatar Antonio Politi
Browse files

compare sd of FA and matlab fit

parent dcfd95c5
# compare standard deviation of different measurments with fits std and FluctuationAnalyzer estimated std
# Author: Antonio Politi
library('ggplot2')
# import data ----
setwd('C:\\Users\\toni\\Dropbox\\NPCMaturation\\matlabcode\\FCS\\example_data\\Alexa')
fitfiles <- list.files(pattern = '*.1c_opt.cof')
corfiles <- list.files(pattern = '*.1c_opt.cor')
fitall <- list()
for (i in seq_along(fitfiles)) {
cof <- read.csv(fitfiles[i], sep = '\t')
cof <- cof[, c(1,2,3,4,5)]
cof <- na.omit(cof)
colnames(cof) <- c('tau', 'Ch1', 'fitCh1', 'Ch2', 'fitCh2')
cor <- read.csv(corfiles[i], sep = '\t')
colnames(cor) <- c('tau', 'Ch1', 'sdCh1', 'Ch2', 'sdCh2')
idx <- match(cof$tau, cor$tau)
cof$sdfitCh1 <- sqrt((cof$fitCh1 - cof$Ch1)^2)
cof$sdfitCh2 <- sqrt((cof$fitCh2 - cof$Ch2)^2)
cof <- cbind(cof, cor[idx, c('sdCh1', 'sdCh2')])
cof$id <- i
fitall <- rbind(fitall, cof)
}
# plot data -----
msd <- aggregate(cbind(Ch1, sdCh1, sdfitCh1) ~ tau, data = fitall, function(fitall) c(mean = mean(fitall), sd = sd(fitall)))
ggplot(data = msd ) +
geom_point(aes(x= tau, y = Ch1[,'sd'], color = 'sd (avg. 6 rep.)')) +
geom_point(aes(x= tau, y = sdfitCh1[, 'mean'], color = 'sqrt((G_exp - G_fit)^2)')) +
geom_point(aes(x= tau, y = sdCh1[, 'mean'], color = 'sd_FA')) +
geom_point(aes(x= tau, y = sdCh1[, 'mean']/sqrt(20), color = 'sd_FA/sqrt(20)')) +
scale_x_continuous(trans = 'log') + ylab('Estimated standard deviation') + guides(color=guide_legend(title=NULL))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment