# #——风格,回声= FALSE,结果= '飞机 '-------------------------------------------------------- BiocStyle:减价()选项(宽度= 100,max.print = 1000) knitr:: opts_chunk设置(eval = as.logical (Sys美元。采用“KNITR_EVAL”,“真正的”)),缓存= as.logical (Sys。采用“KNITR_CACHE”,“真正的”)),错误= FALSE ) ## ------------------------------------------------------------------------------------------------- 图书馆(GenomicRanges) gr < -农庄(seqnames = paste0(“空空”,c(1:22说,尾(信件、11))),范围= IRanges(= 33秒开始,宽度= 1000),链= c(代表(“+”,10),代表(“-”,23)),得分= 33,GC = seq (1,0,长度= 33 )) ## ---- se-data -------------------------------------------------------------------------------------- 数据< -矩阵(1:180 ncol = 9, byrow = TRUE) # #——se-gr ---------------------------------------------------------------------------------------- gr_20gene < -农庄(seqnames = paste0(“基因”,1:20),范围= IRanges(开始= 1:20,宽度= 1000),链= c(代表(“+”,10),代表(“-”,10)),得分= 1:20,GC = seq(1 0长度= 20 )) ## ----- 垫 ----------------------------------------------------------------------------------------- sample_df < - data.frame(名称= c(“马丁”、“Herve”、“丹”,“马克”,“瓦莱丽”,“吉姆”,“内特”,“保罗”,“Sonali”),性= c(代表(“男性”,4),“女性”,rep(“男性”,3),“女性”))## ----load-pkg,eval = FALSE ------------------------------------------------------------------------- # 源(“//www.andersvercelli.com/biocLite.R”)# biocLite (GenomeInfoDb) # #装饰图案(包=“GenomeInfoDb”)# # ? sortSeqlevels # #——basic-R -------------------------------------------------------------------------------------- ## 阅读数据帧< -系统。df <- read.delim(fname, stringsAsFactors=FALSE) ## Exploring the data class(df) head(df) tail(df) dim(df) colnames(df) sapply(df, class) ## Summarize the data summary(df) table(df$SEX) ## Subset the data df[df$GROUP %in% c("Brain"),“消化 "),] ## ---- gr-pkg --------------------------------------------------------------------------------------- 图书馆(GenomicRanges) gr < -农庄(seqnames = paste0(“空空”,c(1:22说,尾(信件、11))),范围= IRanges(= 33秒开始,宽度= 1000),链= c(代表(“+”,10),代表(“-”,23)),得分= 33,GC = seq (1 0length=33)) ## extract ranges only from染色体3 gr[seqnames(gr) %in% "chr3",] ##提取grange的前5个range。 gr[1:5, ] ## extract the score and sequence column from a GRanges mcols(gr) ## keep only the standard chromosomes (i.e.) from chromosome 1 to 22, x, y,m keepStandardChromosomes(gr) ## change the chromosome naming style to NCBI seqlevelsStyle(gr) <- "NCBI" gr ## gaps in the ranges gaps(gr) ## find degree of overlap for ranges. coverage(gr) ## ----se-ans--------------------------------------------------------------------------------------- library(SummarizedExperiment) ## data for the SummarizedExperiment object sample_df <- data.frame( names=c("Martin", "Herve", "Dan", "Marc", "Valerie", "Jim", "Nate","Paul", "Sonali"), sex=c(rep("Male", 4), "Female", rep("Male", 3), "Female")) gr_20genes <- GRanges(seqnames = paste0("gene", 1:20), ranges = IRanges(start=1:20, width = 1000 ), strand = c(rep("+", 10), rep("-", 10)), score = 1:20, GC = seq(1, 0, length=20)) data <- matrix(1:180, ncol=9, byrow=TRUE) ## create a SummarizedExperiment object core_se <- SummarizedExperiment(assays=data, rowRanges=gr_20genes, colData=DataFrame(sample_df)) core_se ## exploring the SummarizedExperiment object dim(core_se) head(assay(core_se)) # data matrix rowRanges(core_se) # information about the genes colData(core_se) # sample information ## subset the SummarizedExperiment object ## subsetting the sample information core_se[, core_se$sex == "Female"] ## subsetting the gene information core_se[,1:2] ## ----sessionInfo---------------------------------------------------------------------------------- sessionInfo()