This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
x <- rep(0:15, 8) | |
y <- rep(0:7, each=16) | |
shape <- 0:127 | |
df_shapes <- data.frame(x=x, y=y, shape=shape) %>% | |
filter(!shape %in% c(26:31)) #Shapes 26-31 are not defined, so we'll remove those | |
ggplot(data=df_shapes, aes(x,y)) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Macro to add a column with the time in the 'Results' window | |
// The time is calculated from the Frame interval defined by the user | |
// In this macro the time interval is defined by the variable 'interval' | |
// Created by Joachim Goedhart with essential input from Jerome Mutterer (@jmutterer) | |
//Set the interval (alternatively it can be set in ImageJ/FIJI from the menu: [Image > Properties...]) | |
interval=2 | |
Stack.setFrameInterval(interval) | |
//Calculate the time for each frame and add to the results window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Function that returns p-values from randomization/permutation test | |
require(dplyr) | |
require(tidyr) | |
#Set number of randomizations | |
nsteps <- 1000 | |
#Read the dataframe - the example data used below is available at: https://github.com/JoachimGoedhart/PlotsOfData | |
df <- read.csv("Data_wide_example.csv") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(data.table) | |
require(dplyr) | |
#Get a list with all csv files from the directory that is set as 'working directory' | |
filelist = list.files(pattern="*.csv$") | |
#read all csv files with data.table::fread() and put in df_input_list | |
df_input_list <- lapply(filelist, fread) | |
#reading in csv files can also be done using the base R function read.csv(), without needing to load package "data.table": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Several qualitative color palettes that are colorblind friendly | |
#From Paul Tol: https://personal.sron.nl/~pault/ | |
#Code to generate vectors in R to use these palettes | |
Tol_bright <- c('#EE6677', '#228833', '#4477AA', '#CCBB44', '#66CCEE', '#AA3377', '#BBBBBB') | |
Tol_vibrant <- c('#EE7733', '#0077BB', '#33BBEE', '#EE3377', '#CC3311', '#009988', '#BBBBBB') | |
Tol_muted <- c('#332288', '#88CCEE', '#44AA99', '#117733', '#999933', '#DDCC77', '#CC6677', '#882255', '#AA4499', '#DDDDDD') | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Reads a non-tidy (wide) dataframe from csv file and assumes first column to be time, remaining columns measured parameter (Ratio) per condition (Cell). | |
df_wide <- read.csv("FRET-ratio-wide.csv", na.strings = "") | |
#Tidy the data, i.e. long format with each row is variable | |
df_tidy <- gather(df_wide, Cell, Ratio, -Time) | |
######### Calulcate summary statistics to fill dataframe 'df_summary' ######## | |
# This is base R approach | |
df_summary <- data.frame(Time=df_wide$Time, n=tapply(df_tidy$Ratio, df_tidy$Time, length), mean=tapply(df_tidy$Ratio, df_tidy$Time, mean)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# somewhat hackish solution to: | |
# https://twitter.com/EamonCaddigan/status/646759751242620928 | |
# based mostly on copy/pasting from ggplot2 geom_violin source: | |
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r | |
library(ggplot2) | |
library(dplyr) | |
"%||%" <- function(a, b) { |