Matlab coding for AFM raw data post-processing > Hertz model to obtain cell Young's modulus for increasing indentation depths
This repository contains Matlab codes to process Atomic Force Microscopy raw force spectroscopy data obtained on cells with a spherical indenter
All codes were tested on Matlab R2016a version
The raw data are force-spectroscopy .txt files from AFM experiments. They contain four columns: cantilever height [m], cantilever vertical deflection [N], series time [s], segment time [s]. All the experiments in this context were carried out with a Nanowizard 3 microscope from JPK. The built-in software provide .txt files in this form (comments are preceded by #)
Raw data (input) are processed individually with the Matlab code AFM1_contactpoint.m. This code is needed to:
- fit the contact point with the ratio-of-variance method (see Gavara N. 2016),
- ask the user if happy with the contact point fitting,
- correct the drift between extend and retract baselines,
- correct for tip-sample separation. Pre-processed data are obtained as output.
Pre-processed data are fitted individually with the Hertz model for a spherical indenter over a half space for increasing indentation depths. This is achieved with the Matlab code AFM2_youngmodulus.m. This code does the following:
- takes as input the pre-processed data,
- calculates the Young's modulus for increasing indentation depths by Hertz fitting (through the function createFitHertz.m),
- gives as output a summary .xslx or .csv file containing the Young's modulus for each indentation depth for each file.
A retrospective power analysis is performed by AFM3_samplesize.m on the effective modulus averaged per cell. This analysis allows for calculating the minimum sample size needed to obtain a reliable average population value (i.e. a value that remains constant to the addition of further input). This code does the following:
- takes as input the Young's modulus values for maximum indentation averaged per cell (e.g. if 15 force-spectroscopy curves were obtained for a given cell, this will correspond to one line of input for this step; this line will be calculated as the average value of the 15 curves),
- for increasing sample sizes, calculate the effective modulus at convergence (mean and std),
- returns as CV the coefficient of variation for each sample size calculated as std/mean.
This algorithm takes raw file from AFM microscope (.txt) as input and fit the contact point, correct retract drift and tip-sample separation. New .txt files are saved as output in a folder of choice containing cantilever height, vertical deflection, time and segment.
- INPUT - information about the performed AFM experiment need to be entered by the user (spring constant of the cantilever used, input folder and Matlab working folder)
- open input folder and list file names for next step
- FOR cycle which opens one file at the time from the input folder and perform post-processing steps
- open file
- save data from file into arrays
- fit contact point on extend curve
- plot data after fitting the CP for user verification
- save pre-processed file as .txt files in the output folder
This algorithm fits the Hertz model for a spherical indenter on a half space for increasing indentation depths. It takes the files saved with AFM1_contactpoint.m as input and give as output the Young's modulus for each indentation depth for each file (saved as .xslx or .csv file).
- INPUT - information about the performed AFM experiment need to be entered by the user (indenter radius, input folder and Matlab working folder)
- open input folder and list file names for next step
- initialize output arrays
- FOR cycle which opens one file at the time and perform post-processing steps
- open file
- save data from file into arrays
- find Young's modulus for increasing indentation depths (calls createFitHertz.m)
- save output for opened file
- save summary output file for all files
This algorithm calculates the sample size needed to obtain a reliable effective modulus value for the cell population by retrospective power analysis. It takes as input the matrix DATA containing the Young's modulus averaged per cell for all indentation depths (i.e. each row represents one cell, each column one indentation depth), but only considers the maximum indentation depth.
- get the maximum indentation data
- calculate the effective modulus at convergence for increasing sample sizes (WHILE loop for each sample size N until the convergence threshold is reached) 2. draw N cells with replacement (bootstrap) 3. calculate average for the N cells (instant effective modulus) 4. calculate average effective modulus for subsequent draws (cumulative effective modulus) 5. calculate percentage errors 6. check convergence vector
- save effective modulus at convergence for each sample size (average and dispersion)
- return the coefficient of variation (CV) for each sample size using the effective modulus at convergence