install.packages("e1071")
install.packages("klaR")
install.packages("tree")
install.packages("DAAG")
## svm
library(DAAG)
library(caret)
library(e1071)
library(rpart)
aqd <- read.csv("~/Downloads//mccdf_Guting4.csv", header = TRUE, sep = ",")
aqd1 <- aqd[ , c(3, 5:1420)]
newaqd1 <- na.omit(aqd1)
m1 <- svm(pm25~ PM25_Wanli_0 + sea_press_Banqiao_w_6 + sea_press_Banqiao_w_7 + sea_press_Banqiao_w_8
+ sea_press_Banqiao_w_9 + sea_press_Banqiao_w_11 + sea_press_Banqiao_w_12 + sea_press_Banqiao_w_17
+ sea_press_Banqiao_w_18 + sea_press_Banqiao_w_19 + sea_press_Banqiao_w_20 + sea_press_Banqiao_w_21
+ sea_press_Banqiao_w_22 + sea_press_Banqiao_w_23 + temerature_Banqiao_w_0 + temerature_Banqiao_w_1
+ temerature_Banqiao_w_2 + temerature_Banqiao_w_3 + temerature_Banqiao_w_4 + temerature_Banqiao_w_5
+ temerature_Banqiao_w_6 + temerature_Banqiao_w_7 + temerature_Banqiao_w_8 + temerature_Banqiao_w_9
+ temerature_Banqiao_w_22 +  temerature_Banqiao_w_23 +  dew_point_Banqiao_w_0 + dew_point_Banqiao_w_6
+  dew_point_Banqiao_w_7 + dew_point_Banqiao_w_8 +  dew_point_Banqiao_w_9 + dew_point_Banqiao_w_22
+ dew_point_Banqiao_w_23 + visb_Anbu_w_0 +  visb_Anbu_w_20 ,data = newaqd1)
pred = predict(m1, data = newaqd1)
newpred <- as.numeric(round(pred))
newaqd2 <- cbind(newaqd1, newpred)
cM <- table(newaqd2$newpred, newaqd2$pm25)
b <- confusionMatrix(cM)
str(cM)
?confusionMatrix
confusionMatrix(newaqd2$newpred, newaqd2$pm25)
str(newaqd2$newpred)
str(newaqd2$pm25)
cm<-confusionMatrix(as.factor(newaqd2$newpred),as.factor(newaqd2$pm25))
tmp<-as.factor(newaqd2$newpred)
str(tmp)
tmp<-as.factor(newaqd2$pm25)
str(tmp)
cM <- table(as.factor(newaqd2$newpred), as.factor(newaqd2$pm25))
str(cM)
a <- (cM[c(1:74),c(1:74)])
g <- confusionMatrix(a)
str(a)
q()
library("edgeR")
x <- read.delim("fileofcounts.txt",row.names="Symbol")
install.packages("corpcor")
q()
a<-c(1,2)
load("./RData")
load("~/.RData")
save.image("~/test.Rdata")
load("test.Rdata")
save.image("~/test.RData")
pam250 <- read.table("~/Dropbox/13_NCCU/courses/生物資訊概論與實務_Bioinformatics/1051/homeworks/assignment/pro2/PAM250.txt")
head(pam250)
str(pam250)
?print
?text
3^7
c(10,1)
choose(10,1)
choose(10,2)
choose(10,5)
1024-1-1-252
770/2
source("http://wush978.github.io/R/init-swirl.R")
rm(list=ls())
library(swirl);swirl()
skip()
chat()
submit()
?chol2inv
bye()
m <- matrix(c(1, 0, 0, 1), nrow = 2, ncol = 2, byrow = TRUE)
m
m2
mxm
m * m
m <- matrix(c(1, 0, 0, 0, 1, 0, 0,0, 0, 1, 0, 0, 0, 0, 1, 0), nrow = 4, ncol = 4, byrow = TRUE)
m
m * m
m <- matrix(c(1, 1, 0, 1, 0, 1, 1,0, 0, 0, 1, 1, 0, 0, 0, 1), nrow = 4, ncol = 4, byrow = TRUE)
m
m * m
m %*% m
m <- matrix(c(1, 0, 0, 0, 1, 0, 0,0, 0, 1, 0, 0, 0, 0, 1, 0), nrow = 4, ncol = 4, byrow = TRUE)
m %*% m
m %*% m %*% m
s <- matrix(c(0,1,0,0,0,0,1,0,0,0, 1,0,1,0,0,0,0,0,0,0, 0,1,0,1,0,0,0,1,0,0, 0,0,1,0,1,0,0,0,0,0, 0,0,0,1,0,1,0,0,0,0, 0,0,0,0,1,0,1,0,0,0, 1,0,0,0,0,1,0,0,0,1, 0,0,1,0,0,0,0,0,1,0, 0,0,0,0,0,0,0,1,0,1, 0,0,0,0,0,0,1,0,1,0), nrow = 10, ncol = 10, byrow = TRUE)
s
s %*% s
s %*% s + s
power(2,3)
pow(2,3)
2^3
2^3 % 3
mod(2^3,2)
2^3 %% 2
2^3 %% 3
3^111 %% 3
(3^111) %% 3
(3^111)
(3^111) %% 143
(209^3) %% 53
(3^111) %% 143
(3^111) %% 11
(3^111) %% 143
(3^111) %% 11
getwd()
1+1
2^3
install.packages("clusterProfiler")
library("clusterProfiler")
install.packages('devtools')
library(devtools)
install_github('andreacirilloac/updateR')
library(updateR)
updateR()
# for loading rJava
dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
library(rJava)
library("clusterProfiler")
library('RDAVIDWebService')
diagonal
diagonal<-T
diagonal?"diagonal\n":"not diagonal\n"
?layout
?par
?plot.window
xlim <- c(-30,30)
ylim <- c(-5,5)
plot.new()
plot.window( xlim , ylim )
points(1,1)
points(0,0)
xlim <- c(-30,30)
ylim <- c(-5,5)
plot.window( xlim , ylim )
points(1,1)
points(0,0)
?rect
?polygon
n <- 100
xx <- c(0:n, n:0)
yy <- c(c(0, cumsum(stats::rnorm(n))), rev(c(0, cumsum(stats::rnorm(n)))))
plot   (xx, yy, type = "n", xlab = "Time", ylab = "Distance")
polygon(xx, yy, col = "gray", border = "red")
title("Distance Between Brownian Motions")
op <- par(mfrow = c(2, 1))
plot(c(1, 9), 1:2, type = "n")
op
polygon(1:9, c(2,1,2,1,1,2,1,2,1),
col = c("red", "blue"),
border = c("green", "yellow"),
lwd = 3, lty = c("dashed", "solid"))
par(op)
plot(c(1, 9), 1:2, type = "n")
polygon(1:9, c(2,1,2,1,NA,2,1,2,1),
density = c(10, 20), angle = c(-45, 45))
max(seq(1:100))
?max
range(seq(1:10))
a<-range(seq(1:10))
ap2[]
a[2]
200000/160000
?range
1.1*10^7
1.1*10^7-10720000
160000*1.25
sample(1:10, 1)
sample(1:10, 10)
students <- c("劉子源", "張家偉","李旻融","林信甫","林泰鈺","林洋名",
"楊宗翰","王俊翔","甘岱珺","莊禾暘","藍逵原","蘇勤文",
"許仁傑","許晉銘","陳冠謀","顏碩亨","包諾克","陳志明")
i<-sample(1:length(students), length(students))
students[i]
print(paste("presenter",1:length(students),students[i]))
print(paste("presenter",1:length(students),students[i],"\n"))
print(paste("presenter",1:length(students),students[i]))
print(paste("presenter",1:length(students),"=",students[i]))
cat(paste("presenter",1:length(students),"=",students[i],"\n"))
cat(paste("presenter",1:length(students),"=",students[i],"\n"))
cat(paste("presenter",1:length(students),"=",students[i],"\n"))
i<-sample(1:length(students), length(students))
cat(paste("presenter",1:length(students),"=",students[i],"\n"))
i<-sample(1:length(students), length(students))
cat(paste("presenter",1:length(students),"=",students[i],"\n"))
1,649/272
1649/272
(1649/272)*186
1127/186
1127/3
source("http://bioconductor.org/biocLite.R")
biocLite( "BSgenome" )
biocLite( "Rsamtools" )
biocLite( "ShortRead" )
install.packages("doMC")
10203092-10436611
abs(10203092-10436611)
log10(abs(10203092-10436611))
log10(48,484)
log10(48484)
10^0.2
10^5.1
10^5.2
11977954-11851514
9953-2344
?boxplot
boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
# *add* notches (somewhat funny here):
boxplot(count ~ spray, data = InsectSprays,
notch = TRUE, add = TRUE, col = "blue")
boxplot(count ~ spray, data = InsectSprays,
notch = TRUE, add = TRUE, col = "blue")
boxplot(count ~ spray, data = InsectSprays,
notch = TRUE, add = TRUE, col = "blue")
boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", notch = TRUE)
?plot.new
plot(x,y)
yx.lm <- lm(y ~ x)
lines(x, predict(yx.lm), col="red")
x<-1:10
x
y<-2:22
y<-1:10
plot(x,y)
yx.lm <- lm(y ~ x)
lines(x, predict(yx.lm), col="red")
plot(x,y)
yx.lm <- lm(y ~ x)
lines(x, predict(yx.lm), col="red")
boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
# *add* notches (somewhat funny here):
boxplot(count ~ spray, data = InsectSprays,
notch = TRUE, add = TRUE, col = "blue")
2301126221/3088269832
113170172/3088269832
library("DESeq2")
source("https://bioconductor.org/biocLite.R")
biocLite("DESeq2")
library("DESeq2")
library("pheatmap")
biocLite("pheatmap")
library("pheatmap")
library("RColorBrewer")
library("PoiClaClu")
biocLite("PoiClaClu")
library("PoiClaClu")
library("ggplot2")
library("genefilter")
library("ReportingTools")
biocLite("ReportingTools")
library("ReportingTools")
library("sva")
biocLite("sav")
biocLite("sva")
library("sva")
?merge
q()
library(caret)
install.packages(caret)
install.packages("caret")
library (boot)
?cv.glm
2523.99+26.22=
:
2523.99+26.22
2550.21-87
11,251.31 - 9,770.06
11251.31 - 9770.06
570*40
library('ggplot2'); library('grDevices')
h <- do.call(rbind,
lapply(unique(clus$cluster),
function(c) { f <- subset(d,cluster==c); f[chull(f),]}))
ggplot() +
geom_text(data=d,aes(label=cluster,x=x,y=y,
color=cluster),size=3)  +
geom_polygon(data=h,aes(x=x,y=y,group=cluster,fill=as.factor(cluster)),
alpha=0.4,linetype=0) +
theme(legend.position = "none")
375*5*30
285*2
258+570
(258+570)/2
6857208/14150911
437883479/1024
437883479/(1024*1024)
437883479/(1024*1024*8)
3165*30
3030*30
70000+94950+90900
180*30
440*30
5400+13200
70000+94950+90900+2500
258350+18600
(10*5+16*4+5*3+1*2)/32
8/9
7/9
1000+1-128
873/32
3542*7
read.table("~/Dropbox (jia-ming.chang)/proj/20141027_Yuri_insulator/analysis/20180303_insBind-4-insClass_plotPerClass_deeptools/tabs/MCIFS.CPR6_1.tab")
InData = read.table(File)
InData = read.table("~/Dropbox (jia-ming.chang)/proj/20141027_Yuri_insulator/analysis/20180303_insBind-4-insClass_plotPerClass_deeptools/tabs/MCIFS.CPR6_1.tab")
InData = read.table("~/Dropbox (jia-ming.chang)/proj/20141027_Yuri_insulator/analysis/20180303_insBind-4-insClass_plotPerClass_deeptools/tabs/MCIFS.CPR6_2.tab")
setwd("~/Dropbox (jia-ming.chang)/proj/20141027_Yuri_insulator/analysis/20150708_SF-vs-SFchangRegion_excludeInsulator/")
source("../../../../programs/deeptools/scripts/functions_PlottingSummaryPlotsForSeveralSignals.R")
source("../../../../../Documents/_HiC/programs/deeptools/scripts/functions_PlottingSummaryPlotsForSeveralSignals.R")
library(ggplot2) # you might need to install this library before you can use it (command: install.packages("ggplot2"))
RegGroups = c("allChrs") # indicate the different bed-files that were used with computeMatrix, must be the same order as in the computeMatrix or profiler output, can be just one group, too
SigLabels= c("RAS3_1","RAS3_2","CPR6_1","CPR6_2","CTCF1","CTCF2") # needs same order as the list of computeMatrix output files (Signals)
PlotTogether = "Signal"
GroupColors= c("green","lightgreen","red4","red3","blue","lightblue") # indicate the kind and the correct number of colors depending on how many different signals or regions you would like to plot within the same box
yAxisLabel = "mean SF"
xAxisLabel = "binding site"
i<-1
PlotName = paste("figs/profile",SETS[i],"png",sep=".")
SETS<-c("cpr6_dep", "cpr6_enr", "ctcf_dep", "ctcf_enr")
i<-1
PlotName = paste("figs/profile",SETS[i],"png",sep=".")
PlotTitle= paste("SF around",SETS[i],sep=" ")
Signals= paste("tabs/",SETS[i],c(".RAS3_1.tab",".RAS3_2.tab",".CPR6_1.tab",".CPR6_2.tab",".CTCF1.tab",".CTCF2.tab"),sep="")
PlottingSummaryPlots = function(ListOfInputFiles =  Signals, RegionGroups = RegGroups, Signalnames = SigLabels, Group = PlotTogether,
OutPlotName = PlotName, Title = PlotTitle, YLab = yAxisLabel, XLab = xAxisLabel ){
SumPlots=list()
i=1
for(s in ListOfInputFiles){
InData = ReadingInFidelsSummaryPlots(s,"Regions",RegionGroups,Signalnames[i])
SumPlots[[i]] = InData
i=i+1
}
SumPlots_df = as.data.frame(do.call(rbind, SumPlots))
# order signal as input Signalnames
SumPlots_df$Signal <- factor(SumPlots_df$Signal, Signalnames)
if(Group=="Regions"){
PLOT = ggplot() +  geom_line(data = SumPlots_df, aes(x=bin, y = mean, colour = Regions)) +
theme_bw(base_size = 16) +
facet_grid(Signal~.) +
scale_colour_manual(values=GroupColors,name="") +
theme(panel.grid.minor=element_blank(), panel.grid.major=element_blank()) +
ylab(YLab) + xlab(XLab)+
ggtitle(Title)
}
else{PLOT = ggplot() +  geom_line(data = SumPlots_df, aes(x=bin, y = mean, colour = Signal)) +
theme_bw(base_size = 16) +
facet_grid(Regions~.) +
scale_colour_manual(values=GroupColors,name="") +
theme(panel.grid.minor=element_blank(), panel.grid.major=element_blank()) +
ylab(YLab) + xlab(XLab)+
ggtitle(Title)
}
png(OutPlotName) # change this if you want a pdf, tiff etc.
print(PLOT)
devname=dev.off()
}
i<-1
PlotName = paste("figs/profile",SETS[i],"png",sep=".")
PlotTitle= paste("SF around",SETS[i],sep=" ")
# list of paths to the files produced with computeMatrix (one for each bigWig, obtained with --outFileNameData), _must_ be more than one
Signals= paste("tabs/",SETS[i],c(".RAS3_1.tab",".RAS3_2.tab",".CPR6_1.tab",".CPR6_2.tab",".CTCF1.tab",".CTCF2.tab"),sep="")
## now run the lines above so that your specific info is read into R
ReadingInFidelsSummaryPlots = function(File, Groupsname, Groups, Signalname){
InData = read.table(File)
GroupData_List = list()
k = 2
for(i in c(1:length(Groups))){
GroupData = InData[c(1,k,k+1)]
names(GroupData)= c("bin","mean","std")
GroupData[Groupsname] = Groups[i]
k = k + 2
GroupData_List[[i]] = GroupData
}
AllGroups = do.call(rbind, GroupData_List)
AllGroups$Signal = Signalname
return(AllGroups)
}
ListOfInputFiles =  Signals
RegionGroups = RegGroups
Signalnames = SigLabels
Group = PlotTogether
OutPlotName = PlotName
Title = PlotTitle
YLab = yAxisLabel
XLab = xAxisLabel
SumPlots=list()
i=1
for(s in ListOfInputFiles){
InData = ReadingInFidelsSummaryPlots(s,"Regions",RegionGroups,Signalnames[i])
SumPlots[[i]] = InData
i=i+1
}
head(InData)
View(InData)
head(SumPlots_df)
head(SumPlots)
s
setwd("../20180303_insBind-4-insClass_plotPerClass_deeptools/csvs/")
d<-read.table("C.CPR6_1.tsv")
?read.table
d<-read.table("C.CPR6_1.tsv",skip = 3)
head(d)
d<-read.table("C.CPR6_1.tsv",skip = 2)
head(d)
d<-read.table("C.CPR6_1.tsv",skip = 1)
d<-read.table("C.CPR6_1.tsv",skip = 2)
head(d)
d[,c(15:28)]
d[,c(15:38)]
sel_d<-d[,c(15:38)]
mean(sel_d)
?mean
apply(sel_d, mean)
lapply(sel_d,mean)
sapply(sel_d,mean)
sapply(sel_d,mean,1)
sapply(sel_d,mean,2)
?sapply
apply(sel_d,1,mean)
apply(sel_d,2,mean)
set.seed(3)
y=rnorm(100)
mean(y)
var(y)
sqrt(var(y))
sd(y)
divide <- function(numerator, denominator) { numerator/denominator }
divide(2,1)
divide(denominator=2,numerator=1)
divide(denominator<-2,numerator<-1)
divide(denominator<-2,numerator<-1)
this_is_a_really_long_name <- 2.5
x<-1
good <- function() { x <- 5}
good()
print(x)
bad <- function() { x <<- 5}
bad()
print(x)
y <- seq(1, 10, length.out = 5)
c(T,T,F,F) & c(T,F,T,F)
vec <- c(1,2)
fun <- function(v) { v[[2]]<<-5; print(v)}
fun(vec)
print(vec)
v <- c(1,2)
fun <- function(v) { v[[2]]<<-5; print(v)}
fun(v)
print(v)
v <- c(1,2)
fun <- function(v) { v[[2]]<-5; print(v)}
fun(v)
print(v)
divide <- function(numerator, denominator) { numerator/denominator }
divide(2,1)
divide(denominator=2,numerator=1)
divide(denominator<-2,numerator<-1)
ivide(denominator<-2,numerator<-1)
divide(denominator<-2,numerator<-1)
(divide(denominator<-2,numerator<-1))
a = 1
b = 2
divide <- function(a, b) {b <<- 0;}
divide(b <- a, a <- b)
print(a/b)
a = 1
b = 2
divide <- function(a, b) {print(a/b); b <<- 0;}
divide(b <- a, a <- b)
print(a/b)
divide(b <- 1, a <- 2)
divide(b = 1, a = 2)
a
b
a = 1
b = 2
divide <- function(a, b) {print(a/b); b <<- 0;}
divide(b <- 1, a <- 2)
print(a/b)
A.	set.seed(3)
B.	y=rnorm(100)
C.	sd(y)
D.	mean(y)
E.	var(y)
F.	sqrt(var(y))
set.seed(3)
y=rnorm(100)
sd(y)
mean(y)
var(y)
sqrt(var(y))
install.packages("shiny")
library(shiny)
runExample("01_hello")
runApp('Dropbox/13_NCCU/courses/DataScienceInPractice_資料科學實務/1071/codes/code09/runApp1.R')
setwd("~/Dropbox/13_NCCU/courses/DataScience_資料科學實務/codes/code07.data")
custdata <- read.table('custdata.tsv',header=TRUE,sep='\t')
load("exampleData.rData")
t<-table(custdata$sex,custdata$is.employed)
t[1,2]/sum(t[1,])
t[2,2]/sum(t[2,])
t
summary(custdata)
str(custdata)
summary(custdata)
summary(custdata[is.na(custdata$housing.type), c("recent.move","num.vehicles")])
summary(custdata$Income)
Income = custdata$income/1000
summary(Income)
summary(custdata$income)
