Skip to content

Instantly share code, notes, and snippets.

View dritoshi's full-sized avatar

Itoshi NIKAIDO dritoshi

  • RIKEN/TMDU
  • Japan
  • X @dritoshien
View GitHub Profile
@dritoshi
dritoshi / gist:9204605
Created February 25, 2014 07:46
Calculate melting temperature (Tm)
source("http://bioconductor.org/biocLite.R")
biocLite("HELP")
library("HELP")
calcTm("ATGCATGC")
@dritoshi
dritoshi / gist:ab9c2bc36156cf090228
Created August 26, 2014 04:24
Karabiner private.xml for RStudio
<?xml version="1.0"?>
<root>
<appdef>
<appname>RSTUDIO</appname>
<equal>org.rstudio.RStudio</equal>
</appdef>
<item>
<name>RSTUDIO</name>
<list>
<item>
@dritoshi
dritoshi / gist:1620637
Created January 16, 2012 12:25
get series_id from ExpressionSet (GEOquery)
library(GEOquery)
gse <- getGEO("GSE20861")
a <- t(sapply(sampleNames(gse[[1]]), function(x) { gsm <- getGEO(x); gsm@header$series_id} ))
a
[,1] [,2]
GSM521700 "GSE20859" "GSE20861"
GSM521701 "GSE20859" "GSE20861"
GSM521702 "GSE20859" "GSE20861"
GSM521703 "GSE20859" "GSE20861"
GSM521704 "GSE20859" "GSE20861"
@dritoshi
dritoshi / not work...
Created January 24, 2012 09:36
not work...
method.name <- "test"
setGeneric(method.name, function(object) standardGeneric(method.name))
@dritoshi
dritoshi / gist:2016231
Created March 11, 2012 12:17
as.nyan
as.nyan <- function(x) { cat("ペロペロ(^ω^)\n") }
@dritoshi
dritoshi / gist:2020452
Created March 12, 2012 07:26
Setting up Bioconductor.jp in your R
source("http://bioconductor.org/biocLite.R")
options("BioC_mirror" = "http://bioconductor.jp/")
biocLite("GEOquery")
@dritoshi
dritoshi / gist:2029743
Created March 13, 2012 16:25
My .Rprofile
.First <- function() {
# sources
source("http://bioconductor.org/biocLite.R")
# options
options(
repos = c(CRAN = "http://cran.md.tsukuba.ac.jp/"),
BioC_mirror = "http://bioconductor.jp/",
show.signif.stars = FALSE,
papersize = "a4",
@dritoshi
dritoshi / gist:2069636
Created March 18, 2012 07:31
factor and vector on nchar
> paste("A", 1:10, sep = "")
[1] "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" "A10"
> nchar(paste("A", 1:10, sep = ""))
[1] 2 2 2 2 2 2 2 2 2 3
> factor(paste("A", 1:10, sep = ""))
[1] A1 A2 A3 A4 A5 A6 A7 A8 A9 A10
Levels: A1 A10 A2 A3 A4 A5 A6 A7 A8 A9
> nchar(factor(paste("A", 1:10, sep = "")))
[1] 1 1 1 1 1 1 1 1 2 1
> nchar(as.character(factor(paste("A", 1:10, sep = ""))))
@dritoshi
dritoshi / gist:2168873
Created March 23, 2012 09:21
git で空のディレクトリを管理する

git ではファイル単位の管理なので、空のディレクトリは管理対象にならない。空のディレクトリのなかに .gitkeep を作っておくとよいらしい。

$ find . -type d -empty -not -path './.git*' -exec touch {}\/.gitkeep \;

.gitignore でドットファイルを無視している場合は .gitkeep は無視しないようにする。

$ vi .gitignore
*~
.*
@dritoshi
dritoshi / mci_for_unb_func.r
Created March 30, 2012 11:22
Monte Carlo for Unbounded Integration
x.num <- 10
x <- seq(0.1, 2.5, length = x.num)
m <- 100000
u <- runif(m)
# integration by substitution
cdf <- numeric(x.num)
for ( i in 1:x.num ) {
g <- x[i] * exp( -(u * x[i])^2 / 2)
cdf[i] <- mean(g) / sqrt(2 * pi) + 0.5