Skip to content

Instantly share code, notes, and snippets.

Avatar
🧑‍💻
You'll have to speak up, I'm wearing a towel

Dave Tang davetang

🧑‍💻
You'll have to speak up, I'm wearing a towel
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am davetang on github.
  • I am davetang (https://keybase.io/davetang) on keybase.
  • I have a public key ASD791k70QUxQTjAu2NfaNCa4dhCxY0EnzWk-AT0uqFOSQo

To claim this, I am signing this object:

View plot_gemini.sh
#!/bin/bash
if type -P gemini > /dev/null
then
for SEVERITY in HIGH MED LOW; do
gemini query -q "select impact_so, count(impact_so) from variants where impact_severity == \"$SEVERITY\" group by impact_so order by count(impact_so)" --header *.db > $SEVERITY.tsv
plot_gemini.R $SEVERITY.tsv
rm -f $SEVERITY.tsv
done
View plot_gemini.R
#!/usr/bin/env Rscript
#
# Usage: plot_gemini.R <file.tsv>
#
my_required <- c('ggplot2', 'reshape2', 'ggthemes')
for (my_package in my_required){
if(my_package %in% rownames(installed.packages()) == FALSE){
stop(paste("Please install", my_package, "first"))
}
View hpo_to_term.pl
#!/usr/bin/env perl
# Script to output names and synonyms of HPO terms
use strict;
use warnings;
my $usage = "Usage: $0 <HPO term> [HPO terms]\n";
if (scalar(@ARGV) == 0){
@davetang
davetang / text_to_hpo_term.pl
Last active Mar 18, 2016
Align free text to Human Phenotype Ontology terms
View text_to_hpo_term.pl
#!/usr/bin/env perl
# Strings (the query) present on each line of a file are matched to Human Phenotype Ontology (HPO) terms (the subject)
# If a direct match between the query and subject could not be found, a global alignment is performed
# Alignments will only take place between queries and subjects that are not longer than each
# other by a length of 5 characters (including spaces)
# For example, 'short' and 'microphones' differ by a length of 6 and will not be compared
# The terms 'short' and 'computer' will be aligned because they differ by a length of 3
# Change $threshold if you want to change the length difference threshold
@davetang
davetang / tsv_sum.pl
Last active Sep 4, 2015
Sums the rows and columns of a tab-delimited file
View tsv_sum.pl
#!/usr/bin/env perl
#
# Reads a tab-delimited file with column and row names
# sums the rows and columns and outputs a tab-delimited
# file with an extra row and column for the sums
#
use strict;
use warnings;
@davetang
davetang / mutate_fasta.pl
Last active Nov 6, 2020
Takes a fasta file as input and randomly mutates bases
View mutate_fasta.pl
#!/usr/bin/env perl
# Takes a fasta file as input and randomly mutates bases
use strict;
use warnings;
my $usage = "Usage: $0 <infile.fa> <mutation percent> <seed>\n";
my $infile = shift or die $usage;
my $mutation = shift or die $usage;
@davetang
davetang / random_paired_end.pl
Last active Aug 29, 2015
A script that takes an input fasta and generates properly paired reads
View random_paired_end.pl
#!/usr/bin/env perl
# Simple script that takes an input fasta sequence
# and generates paired end reads
use strict;
use warnings;
my $usage = "Usage: $0 <infile.fa> <read length> <number of pairs> <inner mate distance> <seed>\n";
my $fasta = shift or die $usage;
@davetang
davetang / compare_list.pl
Last active Aug 29, 2015
Script that compares two files of IDs, that are on separate lines
View compare_list.pl
#!/usr/bin/env perl
#
# Script that compares two files of IDs, that are on separate lines
# See http://stackoverflow.com/questions/2933347/comparing-two-arrays-using-perl
#
use strict;
use warnings;
use Array::Utils qw(:all);
View subset_random_seq.pl
#!/usr/bin/env perl
use strict;
use warnings;
my $usage = "Usage: $0 <infile.fa> <number> <length>\n";
my $fasta = shift or die $usage;
my $num = shift or die $usage;
my $len = shift or die $usage;