This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(curatedTCGAData) | |
curatedTCGAData("OV") | |
mae <- curatedTCGAData("OV", assays=c("mRNAArray", "RNASeq2GeneNorm", "RNASeqGene"), dry.run = FALSE) | |
library(TCGAutils) | |
keep <- TCGAsampleSelect(colnames(mae), 11) | |
mae <- mae[, keep, ] | |
mae <- intersectColumns(mae) | |
mae <- intersectRows(mae) | |
library(org.Hs.eg.db) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.cMAE <- function(mae, x, name="newelement"){ | |
el <- ExperimentList(tmp=x) | |
names(el)[1] <- name | |
c(mae, el) | |
} | |
.hasSymbols <- function(x){ | |
mean(c(FALSE, grepl("^[A-Z0-9]{1,6}|^C[0-9]orf[0-9]{1,4}", rownames(x))), na.rm=TRUE) > 0.9 | |
} | |
.isSummarizedExperiment <- function(x){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
simplifyTCGAData <- function(obj, removeRaggedExperiments=TRUE){ | |
##This function will convert mutations to a genes x samples RangedSummarizedExperiment of 1 for non-silent mutations, 1 for silent or no mutation | |
##It will convert segmented copy number to copy number per gene, using a weighted average if there are non-disjunct ranges | |
suppressPackageStartupMessages({ | |
library(TxDb.Hsapiens.UCSC.hg19.knownGene) | |
library(org.Hs.eg.db) | |
library(GenomeInfoDb) | |
}) | |
gn <- genes(TxDb.Hsapiens.UCSC.hg19.knownGene) | |
gn <- keepStandardChromosomes(granges(gn), pruning.mode="coarse") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
metaphlanToPhyloseq <- function( | |
metaphlandir, | |
metadat=NULL, | |
simplify=TRUE){ | |
## tax is a matrix or data.frame with the table of taxonomic abundances, rows are taxa, columns are samples | |
## metadat is an optional data.frame of specimen metadata, rows are samples, columns are variables | |
## if simplify=TRUE, use only the most detailed level of taxa names in the final object | |
## metaphlanToPhyloseq("~/Downloads/metaphlan_bugs_list") | |
.getMetaphlanTree <- function(removeGCF=TRUE, simplify=TRUE){ | |
if (!requireNamespace("ape")) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fracwithin <- function(n){ | |
sam1 <- rnorm(n) | |
ci <- t.test(sam1)$conf.int | |
means <- replicate(100, mean(rnorm(n))) | |
mean(means > ci[1] & means < ci[2]) | |
} | |
set.seed(2) | |
n <- seq(5, 10000, by=2) | |
fraction <- sapply(n, function(i) fracwithin(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "OVC single-cell analysis" | |
author: "Levi Waldron" | |
date: "5/29/2018" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before starting, install the NCBI SRA Tookit: | |
# Debian/Ubuntu: | |
# apt install sra-toolkit | |
# macOS: | |
# brew install sratoolkit | |
# Windows: | |
# see https://tinyurl.com/y845ppaa | |
# Get your dbGaP repository from https://dbgap.ncbi.nlm.nih.gov/aa/wga.cgi?page=list_wishlists | |
# Click "get dbGaP repository key" | |
library(HMP16SData) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(curatedMetagenomicData) | |
library(SummarizedExperiment) | |
library(tidyr) | |
library(ape) | |
simplifynodes <- TRUE | |
makeTaxTable <- function(fullnames){ | |
taxonomic.ranks <- c("Kingdom", "Phylum", "Class", "Order", | |
"Family", "Genus", "Species", "Strain") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## A big SE | |
library(curatedMetagenomicData) | |
library(SummarizedExperiment) | |
library(tidyr) | |
library(ape) | |
simplifynodes <- TRUE | |
makeTaxTable <- function(fullnames){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url1 <- "https://support.illumina.com/content/dam/illumina-support/documents/documentation/chemistry_documentation/samplepreps_nextera/nexterarapidcapture/nexterarapidcapture_exome_targetedregions.bed" | |
url2 <- "https://support.illumina.com/content/dam/illumina-support/documents/documentation/chemistry_documentation/samplepreps_nextera/nexterarapidcapture/nexterarapidcapture_expandedexome_targetedregions.bed" | |
library(rtracklayer) | |
rapidgr <- import(url1, genome="hg19") | |
expandedgr <- import(url2, genome="hg19") | |
library(GenomicRanges) | |
table(countOverlaps(rapidgr, expandedgr)) |