Skip to content

Instantly share code, notes, and snippets.

View anpefi's full-sized avatar
:octocat:
under pressure

Andrés Pérez-Figueroa anpefi

:octocat:
under pressure
View GitHub Profile
@anpefi
anpefi / configMTP
Created October 26, 2017 09:04
Basic configuration file for metapop2 to sun only population analysis and skip all the management
#Configuration file for Metapop2
# This configuration file is an example of configuration file
# See full specification in https://github.com/anpefi/metapop2 or in the README.md file
# This file would run only the population analysis, skipping all the management
name = Test # Identification for this set of parameters. it will be included as part of results' filenames. Do not use withespaces
convert = none # Conversion of the input file to another format. It ignores the remaining configurations. [none/mtp2gp]
debug = false # Debug mode. Set true to print extra info. [true/false]
dec = 4 # Floating point precision
@anpefi
anpefi / msap-tweakNJplot.nb.Rmd
Created May 29, 2017 10:10
For pea¡ple asking how to modify the default NJ tree plotted by msap.
---
title: "msap: tweak NJ plot"
output: html_notebook
---
## Problem
The NJ plot form msap is awful, specially when the number of samples is big (>10). It was not intended to be very exahsutive, just as an exploratory analysis, but people seems to want to show it.
## Solution
We need to replot the NJ modifying the source code form msap.
@anpefi
anpefi / msap-exporPcoaEPS.Rmd
Last active May 29, 2017 09:28
Export PCoA plots from msap analyses to eps format
---
title: "Export PCoA plot in other formats"
output: html_notebook
---
## Problem
Some users of the *msap* package could be interested in exporting plots (PCoA) in a format other than png. Currently this is not implemented in msap.
## Solution
@anpefi
anpefi / Shannon_from_aflps_in_msap.R
Created February 8, 2016 06:55
This script obtains the distribution if Sannon's Index of diversity for all the AFLP loci
# Assuming you have your aflp matrix data with samples in rows and
# loci in columns. The file is a csv file with the format of msap
#Read data
data <- read.csv("aflp.csv", header=TRUE)
#convert to matrix
matN <- as.matrix(data[,4:length(data[1,])])
#Function for sannon index
@anpefi
anpefi / gist-backup.py
Created February 7, 2016 18:51 — forked from iainmcampbell/gist-backup.py
gist backup
#!/usr/bin/env python
# Git clone all my gists
import json
import urllib
from urllib import urlopen
from subprocess import call
import os
@anpefi
anpefi / rEncodeFASTQ.sh
Created February 1, 2016 15:00
A script to convert a gzipped FASTQ file in Solexa 1.3+ quality offset (QUAL+64 encoding) to a FASTQ with Phred/Sanger offset (QUAL+33 encoding).
#!/bin/bash
#
#$ -j y
#$ -v LD_LIBRARY_PATH
#
#######################################################
# rEncodeFASTQ.sh
#
# A script to convert a gzipped FASTQ file in Solexa 1.3+
# quality offset (QUAL+64 encoding) to a FASTQ with
@anpefi
anpefi / g2m.py
Last active January 18, 2016 14:16
Script for conversion of datafiles from Genepop to metapop
#! /usr/bin/env python
__author__="Andres Perez-Figueroa"
__date__ ="$14-jan-2016$"
__version_="2.0"
### Conversor from genepop to metapop
### Requires Biopython
### run: python g2m.py
### The program will ask for your datafile in genepop format
@anpefi
anpefi / AMOVA3states.R
Last active September 22, 2015 08:33
AMOVA between the three methylation types obtained by msap (I-II-III).
### AMOVA between the three methylation types obtained by the package msap
# AMOVA requires a distance matrix between all samples.
# Such distance matrix could be only be built with quantitative data or with binary data.
# In the case of three category variables, we cannot set a distance between two samples
# (is distance between pattern I and III larger than between II and III?).
# This is why population studies of MSAP needs to join patterns II and III as methylated in order to
# build a binary variable to be analysed by AMOVA/PCoA.
# Anyway, we can made a hack *assuming that distance between different states is equal to 1
@anpefi
anpefi / ifttt.sh
Created June 23, 2015 10:16
This is a generic script to send a web request to the maker channel in IFTTT.com in order to trigger an event in any other channel of IFTTT. It requires that Maker channel is activated in your IFTTT acocunt and having at least one recipe using the Event_name as trigger.
#!/bin/sh
# Script to send web request to MAKER channel in IFTTT.com.
# Arguments:
# $1: Event_name (this is the trigger for IFTTT and SHOULD BE configured in a IFTTT recipe in advance)) i.e: cluster_job
# $2: value1 (To be parsed as Maker variable, and be usable in the triggered event) OPTIONAL
# $3: value2
# $4: value3
# EXAMPLE
# Using recipe https://ifttt.com/recipes/301964 If Maker Event "mailto", then send an email to "value1" with subject "value2" and body "value3"
@anpefi
anpefi / fasta2oneline.sh
Last active August 29, 2015 14:16
In order to add some sequences as "contaminants database" in the fastqc analysis, a contaminant file should be provided with the following format: header[tabulation]sequence. Usage: fasta2oneline.sh example.fa > contaminants.txt
#!/bin/bash
# fasta2oneline.sh
# Convert fasta file in one line: header[tab]sequence (useful for fastqc contaminant file, for example)
# Output to the stdout, redirect it to a file
# Usage: fast2oneline.sh x_example.fa > z_contaminants.txt
INPUT_FILE=$1
cat ${INPUT_FILE} | sed '/^$/d' | sed -n '/^>/!{H;$!b};s/$/ \t/;x;1b;s/\n//g;p'