diff --git a/tests/data/.Rhistory b/tests/data/.Rhistory deleted file mode 100644 index 5f45b69..0000000 --- a/tests/data/.Rhistory +++ /dev/null @@ -1,512 +0,0 @@ -??saveObject -library(scRNAseq) -sce <- ZilionisLungData() -library(alabaster.base) -dir_path <- paste(getwd(), "datasets", sep="/") -saveObject(sce, path=paste(dir_path, "zilinoislung", sep="/")) -# install alabaster -BiocManager::install(c("ArtifactDB/alabaster.base")) -BiocManager::install(version = "devel") -# install alabaster -BiocManager::install(c("ArtifactDB/alabaster.base")) -BiocManager::install(version="devel") -BiocManager::install(c("rhdf5")) -q() -BiocManager::install(c("rhdf5")) -q() -install.packages("BiocManager") -BiocManager::install("rhdf5") -BiocManager::install("rhdf5") -BiocManager::install("rhdf5") -BiocManager::install("rhdf5") -BiocManager::install("artifactdb/alabaster") -BiocManager::install("artifactdb/alabaster") -BiocManager::install("artifactdb/alabaster") -# install alabaster -BiocManager::install(c("ArtifactDB/alabaster.base", "ArtifactDB/alabaster.sce", "ArtifactDB/alabaster.mae")) -BiocManager::install(c("ArtifactDB/alabaster.base", "ArtifactDB/alabaster.sce", "ArtifactDB/alabaster.mae")) -BiocManager::install("alabaster") -BiocManager::install("alabaster") -library(scRNAseq) -library(alabaster) -sce <- ZilionisLungData() -sce -saveRDS(sce[1:2000,], file = "/Users/kancherj/Projects/public/biocpy/tutorial/assets/data/zilinoislung.RDS") -saveRDS(sce[,1:2000], file = "/Users/kancherj/Projects/public/biocpy/tutorial/assets/data/zilinoislung.RDS") -saveRDS(sce[:,1:2000], file = "/Users/kancherj/Projects/public/biocpy/tutorial/assets/data/zilinoislung.RDS") -saveRDS(sce[,1:2000], file = "/Users/kancherj/Projects/public/biocpy/tutorial/assets/data/zilinoislung.RDS") -sce[,1:2000] -sce[,1:2000] -subset sce[,1:2000] -subset <- sce[,1:2000] -rowdata(subset) -rowData(subset) -rowRanges(subset) -as.data.frame(rowRanges(sce)) -as.data.frame(as.genomicranges(rowRanges(sce)) -) -as.data.frame(rowRanges(sce)) -unlist(rowRanges(sce)) -names(rowRanges(sce)) -DataFrame(genes=names(rowRanges(sce))) -rowData(sce) <- DataFrame(genes=names(rowRanges(sce))) -sce -rowDAta(sce) -rowData(sce) -saveRDS(sce[,1:2000], file = "/Users/kancherj/Projects/public/biocpy/tutorial/assets/data/zilinois-lung-subset.rds") -y <- rpois(112, lambda=8) -names(y) <- 1:length(y) -y -saveRDS(y, file="atomic_ints_with_names.rds") -sce <- ZilionisLungData() -library(SingleCellExperiment) -counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) -sce <- SingleCellExperiment(counts) -colData(sce) <- DataFrame(bool_null = c(NA, NA, TRUE, TRUE, NA, NA, NA, TRUE, TRUE, NA)) -library(GenomicRanges) -gr <- GRanges(Rle(c("chr2", "chr1", "chr3", "chr1"), 4:1), -IRanges(1:10, width=5), -seqinfo=Seqinfo(c("chr1", "chr2", "chr3"), c(100, 50, 20))) -gr <- GRanges(Rle(c("chr2", "chr1", "chr3", "chr1"), 4:1), -IRanges(1:10, width=-1), -seqinfo=Seqinfo(c("chr1", "chr2", "chr3"), c(100, 50, 20))) -Iranges(1:10) -IRanges(1:10) -IRanges(start=1:10) -IRanges(start=1:10, width=-1) -IRanges(start=1:10, width=1) -IRanges(start=1:10, width=1, end=10:30) -IRanges(start=1:10, width=1, end=11:30) -IRanges(start=1:10, end=11:30) -library(gypsum) -install.packages(gypsum) -install.packages("gypsum") -devtools::install_github("artifactdb/gypsum-R") -library(devtools) -BiocManager::install() -BiocManager::install("gypsum") -library(gypsum) -fetchPermissions("test-R") -path <- "foo/var.txt" -base <- sub(".*/", "", path) -library(gypsum) -tmp <- tempfile() -dir.create(tmp) -write(file=file.path(tmp, "blah.txt"), LETTERS) -dir.create(file.path(tmp, "foo")) -write(file=file.path(tmp, "foo", "bar.txt"), 1:10) -#' -if (interactive()) { -init <- startUpload( -project="test-R", -asset="upload-complete-check", -version="v1", -files=list.files(tmp, recursive=TRUE), -probation=TRUE, -directory=tmp -) -uploadFiles(init, directory=tmp) -#' -# Finishing the upload. -completeUpload(init) -} -install.packages("digest") -init <- startUpload( -project="test-R", -asset="upload-complete-check", -version="v1", -files=list.files(tmp, recursive=TRUE), -probation=TRUE, -directory=tmp -) -accessToken() -setAccessToken() -init <- startUpload( -project="test-R", -asset="upload-complete-check", -version="v1", -files=list.files(tmp, recursive=TRUE), -probation=TRUE, -directory=tmp -) -init <- startUpload( -project="test-R-k", -asset="upload-complete-check", -version="v1", -files=list.files(tmp, recursive=TRUE), -probation=TRUE, -directory=tmp -) -library(scRNAseq) -sce <- fetchDataset("zeisel-brain-2015", "2023-12-14") -sce -library(scuttle_) -library(scuttle) -library(celldex) -hpca_ref <- fetchReference("hpca", "2024-02-26") -scuttle::logNormCounts(sce) -library(SingleR) -sce <- scuttle::logNormCounts(sce) -cell_labels <- SingleR( -test = assays(sce)[["logcounts"]], -ref = assays(hpca_ref)[["logcounts"]] -labels = hpca_ref$label.main) -cell_labels <- SingleR( -test = assays(sce)[["logcounts"]], -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -cell_labels -library(scRNAseq) -sce <- fetchDataset("zeisel-brain-2015", "2023-12-14") -library(scuttle) -library(celldex) -hpca_ref <- fetchReference("hpca", "2024-02-26") -# sce <- scuttle::logNormCounts(sce) -library(SingleR) -cell_labels <- SingleR( -test = assays(sce)[["logcounts"]], -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -cell_labels <- SingleR( -test = sce, -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -cell_labels <- SingleR( -test = sce, -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -sce <- scuttle::logNormCounts(sce) -library(SingleR) -cell_labels <- SingleR( -test = sce, -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -table(cell_labels$labels) -rownames(hpca_Ref) -rownames(hpca_ref) -hpca_ref$label.main -cell_labels <- SingleR( -test = sce, -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -table(cell_labels$labels) -hpca_ref$label.main -View(cell_labels) -View(as.data.frame(cell_labels)) -hpca_ref <- fetchReference("blueprint_encode", "2024-02-26") -sce <- scuttle::logNormCounts(sce) -library(SingleR) -cell_labels <- SingleR( -test = sce, -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -table(cell_labels$labels) -cell_labels$scores -cell_labels$scores$HSC -View(as.data.frame(cell_labels)) -cell_labels$scores.HSC -cell_labels$scores[["HSC"]] -hpca_ref <- fetchReference("immgen", "2024-02-26") -sce <- scuttle::logNormCounts(sce) -library(SingleR) -cell_labels <- SingleR( -test = sce, -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -hpca_ref <- fetchReference("immgen", "2024-02-26") -sce <- scuttle::logNormCounts(sce) -library(SingleR) -cell_labels <- SingleR( -test = sce, -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -library(scRNAseq) -sce <- fetchDataset("zeisel-brain-2015", "2023-12-14") -library(scuttle) -library(celldex) -hpca_ref <- fetchReference("immgen", "2024-02-26") -sce <- scuttle::logNormCounts(sce) -library(SingleR) -cell_labels <- SingleR( -test = sce, -ref = assays(hpca_ref)[["logcounts"]], -labels = hpca_ref$label.main) -library(scRNAseq) -sce <- fetchDataset("zeisel-brain-2015", "2023-12-14") -library(scuttle) -library(celldex) -hpca_ref <- fetchReference("immgen", "2024-02-26") -library(SingleR) -cell_labels <- SingleR( -test = assay(sce, "counts")[,1:100], -ref = hpca_ref, -labels = hpca_ref$label.main) -hpca_ref <- fetchReference("immgen", "2024-02-26") -sce <- scuttle::logNormCounts(sce) -library(SingleR) -cell_labels <- SingleR( -test = assay(sce, "counts")[,1:100], -ref = hpca_ref, -labels = hpca_ref$label.main) -bpnworkers(BPPARAM) -cell_labels <- SingleR( -test = assay(sce, "counts")[,1:100], -ref = hpca_ref, -labels = hpca_ref$label.main -num.threads=4) -cell_labels <- SingleR( -test = assay(sce, "counts")[,1:100], -ref = hpca_ref, -labels = hpca_ref$label.main, -num.threads=4) -library(scRNAseq) -sce <- fetchDataset("zeisel-brain-2015", "2023-12-14", realize.assays=TRUE) -library(scuttle) -library(celldex) -hpca_ref <- fetchReference("immgen", "2024-02-26", realize.assays=TRUE) -sce <- scuttle::logNormCounts(sce) -library(SingleR) -cell_labels <- SingleR( -test = assay(sce, "counts")[,1:100], -ref = hpca_ref, -labels = hpca_ref$label.main, -num.threads=4) -library(GenomicRanges) -gr <- GenomicRanges( -seqnames = c("chr1", "chr1"), -ranges = IRanges(c(2, 9), width=c(6, 11)), -strand = c("+", "-")) -gr <- GRanges( -seqnames = c("chr1", "chr1"), -ranges = IRanges(c(2, 9), width=c(6, 11)), -strand = c("+", "-")) -gr2 <- GRanges( -seqnames = c("chr1"), -ranges = IRanges(c(5), width=c(6)), -strand = c("-")) -intersect(gr, gr2) -intersect(gr2, gr) -library(AnnotationHub) -ahub = AnnotationHub() -ahub -library(TxDb.Hsapiens.UCSC.hg38.knownGene) -BiocManager::install(library(TxDb.Hsapiens.UCSC.hg38.knownGene)) -BiocManager::install(TxDb.Hsapiens.UCSC.hg38.refGene) -BiocManager::install("TxDb.Hsapiens.UCSC.hg38.refGene") -library(TxDb.Hsapiens.UCSC.hg38.refGene) -TxDb.Hsapiens.UCSC.hg38.refGene -library(genomicranges) -library(GenomicRanges) -as.granges(TxDb.Hsapiens.UCSC.hg38.refGene) -genome <- TxDb.Hsapiens.UCSC.hg38.refGene -genome -transcripts(genome) -seqlevels() -seqlevels(genome) -filtered <- keepSeqlevels( -txpts, -c("chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", -"chr9", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16", -"chr17", "chr18", "chr19", "chr20", "chr21", "chr22", "chrX", -"chrY" -) -) -BiocManager::install("TxDb.Hsapiens.UCSC.hg38.refGene") -library(TxDb.Hsapiens.UCSC.hg38.refGene) -genome <- TxDb.Hsapiens.UCSC.hg38.refGene -txpts <- transcripts(genome) -filtered <- keepSeqlevels( -txpts, -c("chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", -"chr9", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16", -"chr17", "chr18", "chr19", "chr20", "chr21", "chr22", "chrX", -"chrY" -) -) -seqname(genome) -seqnames(genome) -subset(txpts, seqnames(txpts) %in% c("chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", -"chr9", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16", -"chr17", "chr18", "chr19", "chr20", "chr21", "chr22", "chrX", -"chrY" -)) -x <- GRanges("chr1", IRanges(c(2, 9) , c(7, 19)), strand=c("+", "-")) -library(GenomicRanges) -x <- GRanges("chr1", IRanges(c(2, 9) , c(7, 19)), strand=c("+", "-")) -y <- GRanges("chr1", IRanges(5, 10), strand="*") -subtract(x,y) -ignore.strand = FALSE -minoverlap = 1 -y <- reduce(y, ignore.strand=ignore.strand) -hits <- findOverlaps(x, y, minoverlap=minoverlap, -ignore.strand=ignore.strand) -hits -extractList(y, as(hits, "IntegerList")) -library(GenomicRanges) -x <- GRanges("chr1", IRanges(c(2, 9) , c(7, 19)), strand=c("+", "-")) -y <- GRanges("chr1", IRanges(5, 10), strand="+") -subtract(x,y) -ignore.strand = FALSE -minoverlap = 1 -y <- reduce(y, ignore.strand=ignore.strand) -hits <- findOverlaps(x, y, minoverlap=minoverlap, -ignore.strand=ignore.strand) -extractList(y, as(hits, "IntegerList")) -ans <- psetdiff(x, extractList(y, as(hits, "IntegerList"))) -ans -x = IRanges(c(1, 5, -2, 0, 14), width=c(10, 5, 6, 12, 4)) -y = IRanges(c(14, 0, -5, 6, 18), width=c(7, 3, 8, 3, 3)) -overlaps(x,y) -find_overlaps(x,y) -library(IRanges) -x = IRanges(c(1, 5, -2, 0, 14), width=c(10, 5, 6, 12, 4)) -y = IRanges(c(14, 0, -5, 6, 18), width=c(7, 3, 8, 3, 3)) -find_overlaps(x,y) -findOverlaps(x,y) -findOverlaps(x,y, type="within") -findOverlaps(x,y, type="start") -library(tximportData) -BiocManager::install("tximportData") -dir <- system.file("extdata", package = "tximportData") -list.files(dir) -library(TxDb.Hsapiens.UCSC.hg19.knownGene) -BiocManager::install("TxDb.Hsapiens.UCSC.hg19.knownGene") -txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene -k <- keys(txdb, keytype = "TXNAME") -tx2gene <- select(txdb, k, "GENEID", "TXNAME") -library(TxDb.Hsapiens.UCSC.hg19.knownGene) -txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene -k <- keys(txdb, keytype = "TXNAME") -tx2gene <- select(txdb, k, "GENEID", "TXNAME") -library(tximport) -txi <- tximport(files, type = "salmon", tx2gene = tx2gene) -BiocManager::install("tximport") -library(tximport) -txi <- tximport(files, type = "salmon", tx2gene = tx2gene) -files <- file.path(dir, "salmon", samples$run, "quant.sf.gz") -names(files) <- paste0("sample", 1:6) -all(file.exists(files)) -samples <- read.table(file.path(dir, "samples.txt"), header = TRUE) -samples -files <- file.path(dir, "salmon", samples$run, "quant.sf.gz") -names(files) <- paste0("sample", 1:6) -all(file.exists(files)) -library(tximport) -txi <- tximport(files, type = "salmon", tx2gene = tx2gene) -txi <- tximport(files, type = "salmon", tx2gene = tx2gene, ignoreTxVersion=TRUE) -names(txi) -txi <- tximport(files, type = "salmon", tx2gene = tx2gene, -ignoreTxVersion=TRUE, ignoreAfterBar=TRUE) -library(readr) -BiocManager::install("readr") -library(tximport) -txi <- tximport(files, type = "salmon", tx2gene = tx2gene) -tx2gene -library(tximportData) -dir <- system.file("extdata", package = "tximportData") -list.files(dir) -library(TxDb.Hsapiens.UCSC.hg19.knownGene) -txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene -k <- keys(txdb, keytype = "TXNAME") -tx2gene <- select(txdb, k, "GENEID", "TXNAME") -samples <- read.table(file.path(dir, "samples.txt"), header = TRUE) -samples -library(readr) -tx2gene <- read_csv(file.path(dir, "tx2gene.gencode.v27.csv")) -BiocManager::install("readr") -library(readr) -tx2gene <- read_csv(file.path(dir, "tx2gene.gencode.v27.csv")) -head(tx2gene) -files <- file.path(dir, "salmon", samples$run, "quant.sf.gz") -names(files) <- paste0("sample", 1:6) -all(file.exists(files)) -library(tximport) -txi <- tximport(files, type = "salmon", tx2gene = tx2gene) -names(txi) -txi -class(txi) -txi.sum <- summarizeToGene(txi.tx, tx2gene) -all.equal(txi$counts, txi.sum$counts) -library(DESeq2) -BiocManager::install("DESeq2") -library(DESeq2) -sampleTable <- data.frame(condition = factor(rep(c("A", "B"), each = 3))) -rownames(sampleTable) <- colnames(txi$counts) -dds <- DESeqDataSetFromTximport(txi, sampleTable, ~condition) -library(DESeq2) -library(DESeq2) -sampleTable <- data.frame(condition = factor(rep(c("A", "B"), each = 3))) -rownames(sampleTable) <- colnames(txi$counts) -dds <- DESeqDataSetFromTximport(txi, sampleTable, ~condition) -dds -files <- file.path(dir, "salmon_gibbs", samples$run, "quant.sf.gz") -names(files) <- paste0("sample", 1:6) -txi.inf.rep <- tximport(files, type = "salmon", txOut = TRUE) -names(txi.inf.rep) -library(tximport) -txi.inf.rep <- tximport(files, type = "salmon", txOut = TRUE) -names(txi.inf.rep) -names(txi.inf.rep$infReps) -library(DESeq2) -sampleTable <- data.frame(condition = factor(rep(c("A", "B"), each = 3))) -rownames(sampleTable) <- colnames(txi$counts) -dds <- DESeqDataSetFromTximport(txi, sampleTable, ~condition) -dds -colData(dds) -rowData(dds) -txi -names(txi) -files <- file.path(dir, "salmon_gibbs", samples$run, "quant.sf.gz") -names(files) <- paste0("sample", 1:6) -txi.inf.rep <- tximport(files, type = "salmon", txOut = TRUE) -names(txi.inf.rep) -names(txi.inf.rep$infReps) -names(txi) -names(txi.inf) -View(txi.inf.rep) -txi -names(txi) -txi$counts -dims(txi$counts) -dim(txi$counts) -files <- file.path(dir, "salmon", samples$run, "quant.sf.gz") -names(files) <- paste0("sample", 1:6) -txi.salmon <- tximport(files, type = "salmon", tx2gene = tx2gene) -head(txi.salmon$counts) -dim(txi.salmon$counts) -txi.inf.rep -names(txi.inf.rep) -names(txi.inf.rep$counts) -dim(txi.inf.rep$counts) -library(GenomicRanges) -gr <- GRanges( -seqnames = c("chr1", "chr1"), -ranges = IRanges(c(2, 9), width=c(6, 11), mcols=DataFrame(a = 1:2)), -strand = c("+", "-")) -gr -rnges(gr) -ranges(gr) -ir <- IRanges(c(2, 9), width=c(6, 11), mcols=DataFrame(a = 1:2)) -ir <- IRanges(c(2, 9), width=c(6, 11), mcols=DataFrame(a = 1:2)) -gr <- GRanges( -seqnames = c("chr1", "chr1"), -ranges = ir, -strand = c("+", "-")) -gr -ir -mcols(gr) -setwd("~/Projects/public/BiocPy/rds2py/tests/data") -y <- 10 -saveRDS(y, file="scalar_int.rds") -type(y) -x <- c(10, 20) -type(x) -class(x) -class(y) -z <- c(10) -x == z -x == y -z == y -y -z -x