Skip to content

Instantly share code, notes, and snippets.

View davetang's full-sized avatar
🦀
🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀

Dave Tang davetang

🦀
🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀🦀
View GitHub Profile
@davetang
davetang / read_bam.R
Last active January 19, 2023 18:18
Read in BAM file and store as a data frame using Bioconductor's Rsamtools
#install if necessary
source("http://bioconductor.org/biocLite.R")
biocLite("Rsamtools")
#load library
library(Rsamtools)
#read in entire BAM file
bam <- scanBam("wgEncodeRikenCageHchCellPapAlnRep1.bam")
#!/usr/bin/env bash
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release \
@davetang
davetang / biomart_refseq.R
Last active May 12, 2022 06:55
Using biomaRt to fetch all human mRNA refSeqs and their corresponding chromosome coordinates
#install if necessary
source("http://bioconductor.org/biocLite.R")
biocLite("biomaRt")
#load library
library("biomaRt")
#use ensembl mart
ensembl <- useMart("ensembl",dataset="hsapiens_gene_ensembl")
@davetang
davetang / split_search.sh
Created December 8, 2021 03:40
Run grep in parallel
#!/usr/bin/env bash
set -euo pipefail
usage() {
>&2 echo "Usage: $0 [ -l search_list ] [ -f file_to_grep ] [ -n split_num ] [ -p num_threads ]"
exit 1
}
num_param=4
#!/usr/bin/env perl
use strict;
use warnings;
my $data = [];
my $t_data = [];
while(<>){
chomp;
@davetang
davetang / psl_to_bed_best_score.pl
Last active April 9, 2021 13:55
A more documented version of my psl_to_bed_best_score.pl script at http://davetang.org/wiki/tiki-index.php?page=Blat.
#!/usr/bin/env perl
use strict;
use warnings;
=head1 NAME
This scripts converts a psl file into a bed file written by Dave Tang.
=head1 SYNOPSIS
@davetang
davetang / mutate_fasta.pl
Last active November 6, 2020 10:58
Takes a fasta file as input and randomly mutates bases
#!/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;

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:

@davetang
davetang / intersect_coordinate.R
Last active May 1, 2018 18:43
Given two list of coordinates, find the ones that overlap/intersect
#install if necessary
source("http://bioconductor.org/biocLite.R")
biocLite("GenomicRanges")
#load library
library(GenomicRanges)
#create a GRanges object given an object, my_refseq_loci
head(my_refseq_loci,2)
# refseq_mrna chromosome_name transcript_start transcript_end strand
@davetang
davetang / random_region.R
Last active April 17, 2018 20:56
Sampling random regions of the hg19 genome and obtaining the corresponding sequence
#how many regions to sample?
number <- 50000
#how many bp to add to start
span <- 4
#some necessary packages
#install if necessary
source("http://bioconductor.org/biocLite.R")
biocLite("BSgenome")