This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env perl | |
use strict; | |
use warnings; | |
print "My very first Gist on GitHub!\n"; | |
exit(0); | |
__END__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install if necessary | |
source("http://bioconductor.org/biocLite.R") | |
biocLite("Rsamtools") | |
#load library | |
library(Rsamtools) | |
#read in entire BAM file | |
bam <- scanBam("wgEncodeRikenCageHchCellPapAlnRep1.bam") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install if necessary | |
install.packages('gtools') | |
#load library | |
library(gtools) | |
#urn with 3 balls | |
x <- c('red', 'blue', 'black') | |
#pick 2 balls from the urn with replacement | |
#get all permutations | |
permutations(n=3,r=2,v=x,repeats.allowed=T) | |
# [,1] [,2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#use chr22 as an example | |
#how many entries on the negative strand of chr22? | |
table(bam_df$rname == 'chr22' & bam_df$flag == 16) | |
# FALSE TRUE | |
#3875997 24413 | |
#function for checking negative strand | |
check_neg <- function(x){ | |
if (intToBits(x)[5] == 1){ | |
return(T) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install if necessary | |
install.packages('gtools') | |
#load library | |
library(gtools) | |
#urn with 3 balls | |
x <- c('red', 'blue', 'black') | |
#pick 2 balls from the urn with replacement | |
#get all permutations | |
permutations(n=3,r=2,v=x) | |
# [,1] [,2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perm_without_replacement <- function(n, r){ | |
return(factorial(n)/factorial(n - r)) | |
} | |
#16 choices, choose 16 | |
perm_without_replacement(16,16) | |
#[1] 2.092279e+13 | |
#16 choices, choose 3 | |
perm_without_replacement(16,3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comb_with_replacement <- function(n, r){ | |
return( factorial(n + r - 1) / (factorial(r) * factorial(n - 1)) ) | |
} | |
#have 3 elements, choosing 3 | |
comb_with_replacement(3,3) | |
#[1] 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env Rscript | |
#usage | |
usage <- 'Usage: cmd_line_param.R <integer_1> <integer_2>'; | |
#store command line arguments | |
args <- commandArgs(trailingOnly = T) | |
#conditional checks | |
if (length(args) != 2){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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") |
OlderNewer