Skip to content

Instantly share code, notes, and snippets.

View janxkoci's full-sized avatar

Jeňa Kočí janxkoci

View GitHub Profile
@janxkoci
janxkoci / bamfilter_oneliners.md
Created January 12, 2024 22:52 — forked from davfre/bamfilter_oneliners.md
SAM and BAM filtering oneliners
@janxkoci
janxkoci / estlgo2slendr.awk
Last active January 2, 2024 16:01
Convert legofit model with estimates to a slendr simulation script
#!/usr/bin/awk -f
function usage()
{
print "Convert legofit model with estimates to slendr simulation script." > "/dev/stderr"
print "usage: estlgo2slendr.awk model.lgo" > "/dev/stderr"
err_exit = 1
exit 1
}
@janxkoci
janxkoci / legofit_jobarray.sh
Created June 8, 2023 16:37
rerun failed legofit jobs from job array at MetaCentrum (PBS Pro)
#!/bin/bash
#PBS -l select=1:ncpus=64:mem=1gb,walltime=24:00:00
## GO TO WORKDIR
cd $PBS_O_WORKDIR || exit
## EXPORT PATH
export PATH="/storage/brno2/home/jena/bin:$PATH"
export PATH="/storage/brno2/home/jena/miniconda3/bin:$PATH"
@janxkoci
janxkoci / meanfaslen.jl
Created January 24, 2023 12:37
my first ever Julia script - reads fasta from stdin and prints mean length of sequences
# julia shebang here
# mean fasta length
# non-fasta input may lead to division by zero !!
# use at your own risk
# add global constants for vars in loop below
# actually - requires julia v1.8+
nseq::Int = 0
len::Int = 0
@janxkoci
janxkoci / vcf2hetfa.sh
Created January 6, 2023 22:26
a wrapper script for vcf2hetfa,pl from the SGDP project
#!/bin/bash
## bash vcf2hetfa.sh input.vcf.gz
VCF=$1
OUT=$(basename -s .vcf.gz $VCF).hetfa.fa
TMP=${OUT}.tmp
rm $OUT # output build by appending, so remove old versions first
@janxkoci
janxkoci / derived.awk
Last active February 1, 2023 12:27
get derived allele counts for set of populations (HQ archaics, africans)
#!/usr/bin/awk -f
BEGIN {
OFS = "\t"
print "chrom_pos", "ref", "alt", "aa", "da", "Altai", "Denisova3", "Chagyrskaya", "Vindija", "Africa"
}
$4 == $5 { # chimp matches gorilla
## concatenate African genotypes to a string (columns 10..NF)
@janxkoci
janxkoci / fasta2tsv.r
Last active August 9, 2022 11:12
Hetfa tools - convert hetfa (fasta) to tsv and to vcf.
#!/usr/bin/env Rscript
# library(seqinr)
## ARGS
args <- commandArgs(trailingOnly=TRUE)
if (length(args) != 2) stop("Two input files must be supplied.", call.=FALSE)
## INPUT
fastafile <- grep(".fa", args, val=T) # args[1] # "mez1_chr21-22.fa"
@janxkoci
janxkoci / jupyterlab_Rshortcuts.json
Created April 7, 2022 19:45
jupyterlab settings - json view - R keyboard shortcuts
// R keyboard shortcuts for jupyterlab
{
"command": "notebook:replace-selection",
"selector": ".jp-Notebook",
"keys": ["Ctrl Shift M"],
"args": {"text": " %>% "}
},
{
"command": "notebook:replace-selection",
"selector": ".jp-Notebook",
@janxkoci
janxkoci / plink_cluster_bfile.sh
Last active May 6, 2022 15:01
scripts for plink clustering (MDS and PCA) using either plink or VCF formats as input
@janxkoci
janxkoci / est2lgo.awk
Created January 27, 2022 16:46
(g)awk script to rewrite a lgo file using legofit estimates, for use with legosim
#!/usr/bin/awk -f
## USAGE
## awk -f est2lgo.awk model_est.txt model.lgo
BEGIN {OFS="\t"}
# read EST file and save param values into array
# note: array includes also header, but that won't match, so nobody cares
NR==FNR {a[$1]=$2; next}