Data Fetching
Determine Download Parameter AFM txt-files
# path to AFM files on the server or a local machine, all files in that folder will be read
setwd("/Users/joergheintz/Documents/06_Projects/FrictionCellMembranes")
mypath <- "/Users/joergheintz/Documents/06_Projects/FrictionCellMembranes/02_Data"
# provide number of lines that need to be skipped, header of AFM file
fileLineOffset <- 12
# spring constant alpha
alpha = 2.93
# provide column numbers
ColumnsOfInterest <- c(1,7,8) # provide columnames tha need to be read in. predefined is x, y-trace, y-retrace
lowlimit = 513 #read lines from "lowlimit" to "uplimit" from each AFT txt file
uplimit = 4096 #read lines from "lowlimit" to "uplimit" from each AFT txt file
# collect and stores data from the raw AFM files
myRawData<-Ingestion(alpha = alpha, ColumnsOfInterest = ColumnsOfInterest, fileLineOffset = fileLineOffset,
mypath = mypath, lowlimit = lowlimit , uplimit = uplimit)
Ingestion and Processing
Data Manipulation for Plotting
# Determining trace or retrace, this file reads the csv file that is generated in the "Ingestion" function
myfilename<-"CellMembrane_Friction_20170324.csv"
y_trace__y_retrace<-"y_trace" # options are y_trace / Y_retrace
# Reads from the RawData File a data subset
#. e.g. trace or retrace, and categorical variables from the AFM
mydata<-PreprocessingIngestedRawData(myfilename = myfilename, y_trace__y_retrace = y_trace__y_retrace)
# create a cellmembrane color scale
colSet <- "Set1"
myColors <- brewer.pal(5,colSet)
names(myColors) <- levels(mydata$system)
colSc <- scale_colour_manual(name = "system",values = myColors)
# Case Definitions
GelPEMvsFullsytem_2nN_50nN <- as.logical(mydata$system == "GelPEM" | mydata$system == "FullSystem")
GelPEMvsFullsytem_2nN <- as.logical((mydata$system == "GelPEM" | mydata$system == "FullSystem") & mydata$f_on_samp == "2nN")
GelPEMvsGelvsFullsytem_2nN <- as.logical((mydata$system == "GelPEM" | mydata$system == "FullSystem" | mydata$system == "Gel") & mydata$f_on_samp == "2nN")
GelPEMvsGelvsFullsytem_2nN_50nN <- as.logical((mydata$system == "GelPEM" | mydata$system == "FullSystem" | mydata$system == "Gel"))
GelPEMvsFullsytem_50nN <- as.logical((mydata$system == "GelPEM" | mydata$system == "FullSystem") & mydata$f_on_samp == "50nN")
GelvsFullsytem_50nN <- as.logical((mydata$system == "Gel" | mydata$system == "FullSystem") & mydata$f_on_samp == "50nN")
GelvsFullsytem_2nN <- as.logical((mydata$system == "Gel" | mydata$system == "FullSystem") & mydata$f_on_samp == "2nN")
#mydata<-mydata[GelPEMvsFullsytem_2nN_50nN, ]
#mydata<-mydata[GelPEMvsFullsytem_2nN, ]
#mydata<-mydata[GelPEMvsGelvsFullsytem_2nN, ]
mydata<-mydata[GelPEMvsGelvsFullsytem_2nN_50nN, ]
#mydata<-mydata[GelPEMvsFullsytem_50nN, ]
#mydata<-mydata[GelvsFullsytem_2nN, ]
#mydata<-mydata[GelvsFullsytem_50nN, ]
Data Processing Pipeline
# Pipeline
## Data PreProcessing, mark sticks and slips
mydata<-StickSlip(mydata, "half_loop")
## Cluster the sticks and slips, provide data.frame and name for the cluster variable
mydata<-BuildCluster(mydata, "st_sl")
## calc residuals / take out linear effect of x
mydata<-InsertResidual(mydata)
## Determine max min slope by dymax/dxmax for each peak
mydata<-MinMaxSlope(mydata)
## Calculate the segmebts (with x, xend=x+dx, y, yend=y+dy
mydata<-Segments(mydata)
## Calculate the segmet for fitted valutes (with x, xend=x+dx, y, yend=y+dy
mydata<-SegmentsFit(mydata)
## write and arrange columns
mydata <- mydata %>% select( ID,half_loop, cluster, mSL, y, dy, dymax, x, dx, dxmax, reg.slope, reg.intercept,
x.fitted, dx.fitted, y.resid, dy.resid, x.fitted.min, x.fitted.max, y.resid.min, y.resid.max, dx.fitted.max, dy.resid.max, slope.fit, alpha, slope, st_sl, xmin:ymax, f_on_samp, system, trace_d, line_rate, length, tip, date)
write.csv(mydata, file = paste(Sys.Date(), "_StickSlip_Cluster_Slope_Segments_", myfilename), row.names = FALSE )

## Histogram Slopes
SlopeHistogram(mydata = mydata, logscale = FALSE, set_x_marker = 0, bi = 1000, low = -2000000, up = 2000000, pr = 0, w = 3, h = 1, colS = colSet)

## Plot Slopes
PlotSlope_1(mydata, logscale = TRUE, c = 3)

## Plot Slopes
PlotSlope_2(mydata, logscale = FALSE, c = 3)

Plotting
## Plotting
PlotCol_RegLine_Fit(mydata, p =0 )

PlotColFit(mydata, c = 3, p = 0, xfitted = 0)
