Hannah Markovic (hmarkovi@uoregon.edu)
June 14, 2019
This program takes pixel coordinate data from images of microridges and analyzes microridge curviness. Microridges are small ridges formed by actin protrusions on the surface of skin cells which are thought to function in mucus retention. The Sagasti lab is interested in the development and function of these ridges in larval zebrafish. These microridges can be labeled on the surface of zebrafish skin cells by using LifeAct-GFP transgenic lines and can then be imaged using confocal microscopy. Some manipulations during development seem to increase the curviness of these ridges, so there was a need for an objective way to measure the "curviness" of the ridges of a cell. Therefore, I wrote the included scripts which output a measure of curvature of each ridge, both as a simple function of the total ridge length divided by the distance between the start and end points of each ridge, and as the sum of the mathematical curvature at each point divided by the total length of the ridge. Kaiser Atai took the images of cells with microridges that appear to be more curved. Aaron Van Loon helped convert these images into a usable format by skeletonizing the ridges and outputting the x and y coordinates of the boundaries of the skeletonized ridge.
Additional information and images can be found at the lab website, under Projects/Skin cell morphogenesis.
Image from Sagasti lab website
There are 3 main scripts included in this repository, along with a master (wrapper) script which can run the program in Hoffman2 (Master_Script.sh).
This is a bash script which concatenates the input csv files, and outputs a single csv (Concatenated_to_analyze.csv) with the concatenated information. It also adds a new column at the beginning of the csv storing each file name.
This is an R script which uses the R package deldir to perform a Voronoi tesselation with the input points (orange). It then uses the package rgeos to find the insersections of the polygons within the pixel boundaries (blue)
The R package PairViz (which requires having the packages TSP and graph installed) is used to perform an open Traveling Salesman Problem algorithm to order these points along the ridge (green), rather than by x value.
It loops this process over every ridge and cell, and saves the information as a csv (OrderedPoints.csv) which is the input for Curvature_Math.rmd
This script calculates average slope and acceleration at each point of the ridge, and then uses the following formula to calculate curvature at each point. It adds these curvature values together, and then divides by the length of the ridge (the column curvature_formula). In addition, it removes any ridges made up of only 1 or 2 coordinates.
It also outputs a more simple measue of curvature obtained by dividing the total ridge length by the distance between the endpoints of the ridge (column curvature_bylength). The output is a csv named OutputCurvatures.csv. For both measures of curvature, a larger number represnts a more curvy ridge.
A Hoffman2 account, or another way to run bash scripts, is required to run this program over multiple files.
- Alternatively, each file could be individually run through Point_Simplifier.rmd and Curvature_Math.rmd, but this would require changing file locations in the scripts every time you run the programs.
You need to install these R packages, using the install.packages("package") command:
I wrote the program using the 3.3.2 version of R.
The data must:
- be in the form of x and y coordinates of the pixels of the skeletonized ridge, and with a column for ridge number.
- be inputted in csv format.
- There cannot be data files with identical names.
- There cannot be spaces in file names.
These scripts can be individually run on your computer, or you can use the master script to run all of them.
All input files must be in the "Files_to_analyze" folder on Hoffman2; or, change the source of the files in the code, and run it on your computer with these files in a folder of your choosing.
To run the program in Hoffman2, follow these commands after cloning this github page, copying your files into Files_to_analyze, and removing delete_this.txt from Files_to_analyze. A detailed example of this is in the Vignette folder if necessary. Begin within the Microridge_Curvature_Analysis directory.
cd Scripts
module load R/3.5.0
R
install.packages("deldir")
install.packages("sp")
install.packages("rgeos")
install.packages("TSP")
source('http://bioconductor.org/biocLite.R')
biocLite('graph')
install.packages("PairViz")
install.packages("tidyverse")
q()
bash Master_Script.sh
If you already have the necessary packages, all you have to do is enter the Scripts directory and type: bash Master_Script.sh
Some notes:
- If you already have R loaded on your terminal, it's sometimes necessary to repeat the line: module load R/3.5.0
- The first time you install a package, it will ask you to select a CRAN mirror
- If it asks to update any packages, say "n".
- It's not necessary to save the workspace image after quitting R.
This program outputs 3 csv files (Concatenated_to_analyze.csv, OrderedPoints.csv, and OutputCurvatures.csv). OutputCurvatures.csv contains the final curvatures for each ridge. An example image of this file is above, under Curvature_Math.rmd. The first column, "cell," contains the original file name. The second, "ridge," contains the ridge numbers of each cell. The third column, "length," contains the length of each ridge. "dist_endpoints" contains the distance between the first and last point of the ridge. "curvature_bylength" contains the result of the length divided by the distance between endpoints. The last column, "curvature_formula," contains the sum of the curvatures at each point of the ridge, determined by the formula above.
Concatenates_to_analyze contains the concatenated x and y coordinates, with file name saved as the first column, which is produced by concatenate.sh. OrderedPoints.csv contains the points used for the final curvature calculations, which were produced by Voronoi tesselation and ordered by a Traveling Salesman Problem algorithm.
Examples of these files can be viewed in the Vignette directory, under Sample_outputs.
Vignette instructions are in the directory named Vignette. There are two test files in the folder, and the output after running the program can be compared to those in the folder Sample_outputs.
- Hannah Markovic
- Biology PhD student at the University of Oregon
- B.S. in Molecular, Cell and Developmental Biology with minor in Biomedical Research, UCLA
- contact: hmarkovi@uoregon.edu
- This program was created as the final project for the class EEB 177, Spring 2019, UCLA
- Aaron van Loon - microridge deconvolution program
- Kaiser Atai - sample data
- Dr. Emily Curd and Daniel Chavez - guidance
doi: 10.5281/zenodo.3245776
Belmonte, Nicolas Garcia. Voronoi Tessellation. https://philogb.github.io/blog/2010/02/12/voronoi-tessellation/.
Bivand, Roger. “Rgeos: Interface to Geometry Engine - Open Source ('GEOS') [R package rgeos version 0.4-3].” The Comprehensive R Archive Network (CRAN), 24 Apr. 2019, https://cran.r-project.org/web/packages/rgeos/.
Dawkins, Paul. “Calculus III - Curvature.” Paul's Online Notes, 29 Nov. 2018, http://tutorial.math.lamar.edu/Classes/CalcIII/Curvature.aspx.
“Graph: A Package to Handle Graph Data Structures.” Bioconductor, www.bioconductor.org/packages/release/bioc/html/graph.html.
Hahsler, Michael, and Kurt Hornick. “Traveling Salesperson Problem (TSP) [R Package TSP Version 1.1-7].” The Comprehensive R Archive Network (CRAN), 22 May 2019, https://cran.r-project.org/web/packages/TSP/.
Hurley, Catherine, and R. W. Oldford. “Package PairViz.” The Comprehensive R Archive Network (CRAN), 9 Aug. 2018, https://cran.r-project.org/web/packages/PairViz/.
“Identify a Linear Feature on a Raster Map and Return a Linear Shape Object Using R.” Stack Overflow, 10 Mar. 2012, https://stackoverflow.com/questions/9595117/identify-a-linear-feature-on-a-raster-map-and-return-a-linear-shape-object-using.
Lizarazo, Ivan. Creation of Spatial Polygons in R. 16 Aug. 2016, https://rstudio-pubs-static.s3.amazonaws.com/202536_7a122ff56e9f4062b6b012d9921afd80.html
Pebesma, Edzer. “Classes and Methods for Spatial Data [R Package Sp Version 1.3-1].” The Comprehensive R Archive Network (CRAN), 5 June 2018, https://cran.r-project.org/web/packages/sp/.
Turner, Rolf. “Package Deldir.” The Comprehensive R Archive Network (CRAN), 4 Jan. 2019, https://cran.r-project.org/web/packages/deldir/.