# #——global_options,包括= FALSE --------------------------------------- 美元knitr: opts_chunk集(警告= FALSE,消息= FALSE, eval = TRUE, fig.width = 7, fig.height = 4.2) # #——load_libraries,结果= '隐藏 '-------------------------------------- 库(rca) # #——sample_data --------------------------------------------------------- 库(rca)数据(queryRegions) #样品queryRegions在床上()数据格式(人造石铺地面)#人造石铺地面文件示例# #——RCAS_import_data,eval = FALSE -------------------------------------- # queryRegions < - importBed (filePath = , sampleN = 10000) # gff <- importGtf(filePath = ) # #——queryGFF ------------------------------------------------------------ < - as.data重叠。table(queryGff(queryRegions = queryRegions, gffData = gff)) ## ----query_gene_types---------------------------------------------------- biotype_col <- grep('gene_biotype', colnames(overlaps), value = T) df <- overlaps[,length(unique(overlappingQuery))), by = biotype_col] colnames(df) <- c("feature", "count") df$percent <- round(df$count / length(queryRegions) * 100,1) df <- df[order(count,递减= TRUE)] ggplot2::ggplot(df, aes(x = reorder(feature, -percent),y = percent)) + geom_bar(stat = 'identity', aes(fill = feature)) + geom_label(aes(y = % + 0.5), label = df$count) + labs(x = 'transcript feature', y = paste0('percent overlap (n = ', length(queryRegions), ')')) + theme_bw(base_size = 14) + theme(轴.text. text. text)。x = element_text(角= 90 )) ## ---- getTxdbFeatures ----------------------------------------------------- txdbFeatures < - getTxdbFeaturesFromGRanges(人造石铺地面)# #——summarizeQueryRegions ----------------------------------------------- 总结< - summarizeQueryRegions (queryRegions = queryRegions txdbFeatures = txdbFeatures) df < - data.frame(总结)df $ % < -轮((df数美元/长度(queryRegions)), 3) * < df 100特性——rownames (df) ggplot2:: ggplot (df, aes (x =重新排序(特性,在建项目),y = percent)) + geom_bar(stat = 'identity', aes(fill = feature)) + geom_label(aes(y = % + 3), label = df$count) + labs(x = 'transcript feature', y = paste0('percent overlap (n = ', length(queryRegions), ')')) + theme_bw(base_size = 14) + theme(轴.text. text. text)。x = element_text(角= 90 )) ## ---- getTargetedGenesTable ----------------------------------------------- dt < - getTargetedGenesTable (queryRegions = queryRegions txdbFeatures = txdbFeatures) dt < - dt(顺序(成绩单、减少= TRUE)] knitr:: kable (dt [1:10 ,]) ## ---- transcriptBoundaryCoverage ------------------------------------------ cvgF < getFeatureBoundaryCoverage (queryRegions = queryRegions featureCoords = txdbFeatures成绩单美元,flankSize = 1000, boundaryType =“fiveprime”,sampleN = 10000) cvgT <- getFeatureBoundaryCoverage(queryRegions = queryRegions, featurecords = txdbFeatures$transcripts, flankSize = 1000, boundaryType = 'three ', sampleN = 10000) cvgF$boundary <- 'fiveprime' cvgT$boundary <- 'three ' df <- rbind(cvgF, cvgT) ggplot2::ggplot(df, aes(x = bases, y = meanCoverage)) + geom_ribbon(fill = 'lightgreen', aes(ymin = meanCoverage - standardError * 1.96,ymax = meanCoverage + standardError * 1.96)) + geom_line(color = 'black') + facet_grid(~ boundary) + theme_bw(base_size = 14) ## ----coverageprofilelist,图.height=6----------------------------------- cvgList <- calculateCoverageProfileList(queryRegions = queryRegions, targetRegionsList = txdbFeatures, sampleN = 10000) ggplot2::ggplot(cvgList, aes(x = bins, y = meanCoverage)) + geom_ribbon(fill = 'lightgreen', aes(ymin = meanCoverage - standardError * 1.96,ymax = meanCoverage + standardError * 1.96)) + geom_line(color = 'black') + theme_bw(base_size = 14) + facet_wrap(~ feature, ncol = 3) ## ----motif_analysis------------------------------------------------------ motifResults <- runmotiffrg (queryRegions = queryRegions, resizeN = 15, sampleN = 10000, genomeVersion = 'hg19', motifN = 2, nCores = 2) par(mfrow = c(1,2),mar = c(2,2,2,2)) for (i in 1:length(motifResults$motifs)) {motifPattern <- motifResults$motifs[[i]]@pattern motifg::plotMotif(match = motifResults$motifs[[i]]@match$pattern, main = paste0('Motif-',i,': ',motifPattern), entropy = TRUE) } ## ----motif_analysis_table------------------------------------------------ summary <- getMotifSummaryTable(motifResults) knitr::kable(summary) ## ----GO analysis--------------------------------------------------------- #get all genes from the GTF data backgroundGenes <- unique(gff$gene_id) #get genes that overlap query regions targetedGenes <- unique(overlaps$gene_id) #run TopGO goBP <- runTopGO(ontology = 'BP', species = 'human', backgroundGenes = backgroundGenes, targetedGenes = targetedGenes) goBP <- goBP[order(goBP$foldEnrichment, decreasing = TRUE),] rownames(goBP) <- goBP$GO.ID goBP <- subset(goBP, select = -c(Annotated,classicFisher, bh, GO.ID)) knitr::kable(goBP[1:10,]) ## ----msigdb_analysis----------------------------------------------------- #geneSets <- parseMsigdb(< path to msigdbFile>) data(geneSets) resultsGSEA <- runGSEA(geneSetList = geneSets, backgroundGenes = backgroundGenes, targetedGenes = targetedGenes) knitr::kable(x = resultsGSEA[1:10,])