Skip to content

Instantly share code, notes, and snippets.

View gaballench's full-sized avatar
🌳

Gustavo A. Ballen gaballench

🌳
View GitHub Profile
@gaballench
gaballench / gist:0afa3385ae000480344e326488ca070c
Last active July 9, 2021 15:33 — forked from brantfaircloth/gist:895282
Substitution models in mrbayes

GTR

lset applyto=() nst=6                           # GTR
lset applyto=() nst=6 rates=propinv             # GTR + I
lset applyto=() nst=6 rates=gamma               # GTR + gamma
lset applyto=() nst=6 rates=invgamma            # GTR + I + gamma

SYM

lset applyto=() nst=6 # SYM

larvaTable <- data.frame(Contrast = names(larvaCor),
Rho = unname(unlist(larvaCor)[grep("estimate", names(unlist(larvaCor)))]),
p.value = unname(unlist(larvaCor)[grep("p.value", names(unlist(larvaCor)))]), stringsAsFactors = FALSE)
symmetry <- c(Asymmetric = sum(table(larvae$Asymmetry)[c("Left", "Right")]),
Symmetric = unname(table(larvae$Asymmetry)[3]))/sum(table(larvae$Asymmetry))*100
gaps <- c(Absent = length(grep("(1)", larvae$LTRF, fixed = TRUE)),
Present = (length(larvae$LTRF) - length(grep("(1)", larvae$LTRF, fixed = TRUE))))/length(larvae$LTRF)*100
@gaballench
gaballench / odds.R
Last active November 17, 2015 20:44
Odds ratio, distance and relative chance in contingency tables
# Written by Gustavo A. Ballen (gaballench at gmail.com)
# https://github.com/gaballench
# The input for this function is a contingency table of class 'xtabs' or 'table' with exposure in rows and cases in columns.
# Internally it uses the 'pi' notation, or for those using ABCD notation there is an equivalence below:
## Model table is as follows
# illness
# exp NO YES
# NO D(1-pi0) C(1-pi1)
@gaballench
gaballench / normalize.R
Last active August 29, 2015 14:27
Normalizer function for continuous characters in TNT
# This data frame 'df' works as an example from Alessio's course. In the real life the data need to be changed for the
# matrix of interest
df <- data.frame(
c1 = c(6,16,12,14,19,6,8,6,14),
c2 = c(5,24,14,17,19,6,5,5,24),
c3 = c(3,26,13,23,17,6,4,4,27),
c4 = c(1,48,6,45,25,5,3,2,47),
c5 = c(NA,10,11,10,15,5,4,4,10),
c6 = c(NA,10,12,10,15,6,5,4,9),
library(png)
#name.file.read.png: png file to make a meme
#name.file.write.png: output png file
#over.text: text over the image
#under.text text under the image
#ps=12: point size, changes the text size
#height: manages the vertical length
#vertical.margin: manages the extra vertical space
@gaballench
gaballench / xlsx.R
Created April 13, 2015 01:51
Ejemplo xlsx
library(xlsx)
datos <- read.xlsx("file.xlsx")
columna <- datos[, "columna_de_interés"]
rm(datos)
@gaballench
gaballench / uniques.py
Created February 17, 2015 03:45
Uniques script for detection of duplicates in the mendeley database
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 23 10:49:34 2014
@author: balleng
"""
import glob
viejo = glob.glob("/home/balleng/Área de trabalho/Mendeley Desktop/*.pdf")
nuevo = glob.glob("/home/balleng/Copy/Mendeley/*.pdf")
#something is wrong with these files. Check. Working.
viejo_nopaths =[x.split('/')[-1] for x in viejo]
@gaballench
gaballench / macbook_trackpad.sh
Created February 17, 2015 03:41
trackpad config for macbook 5.2 w/ ubuntu and/or manjaro
#!/bin/bash
## Script for synaptics trackpad configurations. Working on Macbook 5.2.
## Located in scripts folder, added to startup items through startup configs.
synclient FingerLow=1 && synclient FingerHigh=10
@gaballench
gaballench / rm_dups.sh
Last active August 29, 2015 14:15
Delete duplicate folders with (n) notation
rm echo ls == *"(1).jpg"
@gaballench
gaballench / paste().R
Last active August 29, 2015 14:09
Uso de la función paste()
vec1 <- rep(0, 9)
vec2 <- c(1:9)
total <- paste(vec1, vec2, sep = "")