Skip to content

Instantly share code, notes, and snippets.

@YulongNiu
YulongNiu / summary_count.sh
Created September 12, 2017 13:30
Summary read counts at each nucleotide position for forward and reverse strands
samtools view -b Example_Condition1.sam -o Example_Condition1.bam
samtools view -b Example_Condition2.sam -o Example_Condition2.bam
## reverse
samtools view -h -f 16 Example_Condition1.bam -o Example_Condition1_rev.bam
## forward
samtools view -h -F 16 Example_Condition1.bam -o Example_Condition1_forw.bam
## reverse
samtools view -h -f 16 Example_Condition2.bam -o Example_Condition2_rev.bam
@YulongNiu
YulongNiu / simulated_annealing_max.R
Created July 23, 2017 09:13
Find maximum value by the simulated annealing
SSIndex <- function(i, len, wise = 5) {
min <- i - wise
min <- ifelse(min < 1, 1, min)
max <- i + wise
max <- ifelse(max > len, len, max)
return(seq(min, max))
}
@YulongNiu
YulongNiu / learnS4.R
Last active January 4, 2017 09:03
Example codes in R S4.
##~~~~~~~~~~~~~~~~~~~~~~~~~define class~~~~~~~~~~~~~~~~~~~~~~~~~
## new class
setClass(Class = 'trick',
slots = c(id = 'character', time = 'matrix'),
validity = function(object) {
if (length(object@id) != nrow(object@time)) {
warns <- paste('length of id is', length(object@id), 'is not equal to row number of time', nrow(object@time))
return(warns)
} else {
return(TRUE)