π¦
This file contains hidden or 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; | |
my $usage = "Usage: $0 <matrix.dat>\n"; | |
my $infile = shift or die $usage; | |
my $accession = ''; | |
my $start = 0; |
This file contains hidden or 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("randomForest") | |
#load library | |
library(randomForest) | |
#I have two sets of dinucleotide counts stored in | |
#my_random_loci_seq_di and my_refseq_tss_seq_di | |
head(my_refseq_tss_seq_di,2) |
This file contains hidden or 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("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 |
This file contains hidden or 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
#I want to fetch sequences from | |
#my_random_loci and my_refseq_tss | |
head(my_random_loci,2) | |
chr start end strand | |
1 chr18 59415403 59415407 + | |
2 chr22 8535632 8535636 - | |
#install if necessary | |
source("http://bioconductor.org/biocLite.R") | |
biocLite("BSgenome.Hsapiens.UCSC.hg19") |
This file contains hidden or 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") |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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] |