Skip to content

Instantly share code, notes, and snippets.

weightedMedian <-function(v){
median(rep(v, times = v))
}
@wakuteka
wakuteka / cont_bp.awk
Created March 3, 2011 01:21
d]$ cat *.fa |awk '{if($1!~/^>/)sum+=length}END{print sum}' 173499994 count base pair
#!/bin/awk
BEGIN {
}
{
if($1!~/^>/)
{
sum += length
}
}
END {
#!/bin/sh
#$ -S /bin/bash
pwd
hostname
date
echo arg1=$1
sleep 20
date
@wakuteka
wakuteka / sample.Rnw
Created November 15, 2011 12:32
sweave
\documentclass[a4paper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch}
\begin{document}
\maketitle
In this example we embed parts of the examples from the
@wakuteka
wakuteka / index.snw
Created December 28, 2011 13:49
R2HTML sample
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<!-- vim: set ft=html
Use the following R command to sweave this file:
Sweave("example2.snw",driver=RweaveHTML())
!-->
<<label=zebra,echo=FALSE,eval=TRUE>>=
source("brew-zebra.R")
@
<html>
$ clj
Clojure 1.3.0
(use 'clojure.contrib.classpath)
FileNotFoundException Could not locate clojure/contrib/classpath__init.class or clojure/contrib/classpath.clj on classpath: clojure.lang.RT.load (RT.java:430)
user=> (classpath)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: classpath in this context, compiling:(NO_SOURCE_PATH:2)
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# Perform a google search
doc = Nokogiri::XML(open('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=snp&id=7574865&report=XML&mode=xml'))
# Print out each link using a CSS selector
doc.search('Rs Assembly Component MapLoc FxnSet').each do |link|
puts link.attribute('mrnaAcc').to_s + '.' +link.attribute('mrnaVer').to_s
end
% vim: set filetype=rnoweb
% hoge.Rnw
\documentclass[a4paper]{article}
\usepackage[a4paper,margin=20mm]{geometry}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{center}
<<>>=
plot(1:10)
@
#!/bin/ruby
require 'ensembl'
include Ensembl::Core
DBConnection.connect('homo_sapiens', 60)
my_gene = Gene.find_by_name('BRCA2')
puts my_gene.name + "\t" + my_gene.slice.to_s
my_variations = my_gene.slice.get_valiation_features
puts my_variations.length.to_s + "\t" + my_variations[0].variation_name
# original in http://d.hatena.ne.jp/syou6162/20080801/1217528370
url <- "http://research.microsoft.com/en-us/um/people/cmbishop/PRML/webdatasets/curvefitting.txt"
curvefitting <- read.csv(file=url, sep=" ",head=F)
colnames(curvefitting)<-c("x","t")
takousiki <- function(n){