This file contains hidden or 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(airway) | |
| library(tidySummarizedExperiment) | |
| library(plyxp) | |
| data(airway) | |
| se <- airway | |
| rowRanges(se) <- NULL | |
| forced_conversion <- function(se) { | |
| tib <- tidySummarizedExperiment:::as_tibble.SummarizedExperiment(se) | |
| res <- tib |> |
This file contains hidden or 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
| # adapted from DFplyr | |
| # ignoring rownames and GroupedDataFrame functionality... | |
| left_join.DataFrame <- function(x, y, by = NULL, ...) { | |
| if (is.null(by)) { | |
| by <- intersect(names(x), names(y)) | |
| if (length(by) == 0) { | |
| rlang::abort("`by` must be supplied when `x` and `y` have no common variables.") | |
| } | |
| message("Joining with `by = ", deparse(by), "`") | |
| } |
This file contains hidden or 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
| ❯ checking examples ... [14s/14s] ERROR | |
| Running examples in ‘plyranges-Ex.R’ failed | |
| The error most likely occurred in: | |
| > base::assign(".ptime", proc.time(), pos = "CheckExEnv") | |
| > ### Name: read_bed | |
| > ### Title: Read a BED or BEDGraph file | |
| > ### Aliases: read_bed read_bed_graph read_narrowpeaks | |
| > | |
| > ### ** Examples |
This file contains hidden or 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(here) | |
| library(plyranges) | |
| source(here("analysis/common/import.R")) | |
| # This script imports variant-level summary statistics and adds QC variables | |
| # e.g. | |
| # - sufficient activity of at least one of the alleles | |
| # - balanced representation of reference and | |
| # alternate alleles in the input DNA |
This file contains hidden or 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(GenomicRanges) | |
| library(GenomicFeatures) | |
| library(TxDb.Hsapiens.UCSC.hg38.knownGene) | |
| txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene | |
| ebt <- exonsBy(txdb, by="tx") | |
| cbt <- cdsBy(txdb, by="tx") | |
| fubt <- fiveUTRsByTranscript(txdb) | |
| tubt <- threeUTRsByTranscript(txdb) |
This file contains hidden or 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(DESeq2) | |
| dds <- makeExampleDESeqDataSet() | |
| dds_leaf <- dds[1:500,] | |
| dds_inner <- dds[501:1000,] | |
| dds_leaf <- DESeq(dds_leaf) | |
| res_leaf <- lfcShrink(dds_leaf, coef="condition_B_vs_A", type="apeglm") | |
| # this runs DESeq2 on inner nodes but using priors from leaves | |
| sizeFactors(dds_inner) <- sizeFactors(dds_leaf) | |
| dds_inner <- estimateDispersionsGeneEst(dds_inner) |
This file contains hidden or 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(tidySummarizedExperiment) | |
| library(plyxp) | |
| nfeat <- 1e4 | |
| nsamp <- 1e3 | |
| coldata <- data.frame(x=rep(1:2,length=nsamp)) | |
| assay <- matrix(rnorm(nfeat*nsamp), ncol=nsamp) | |
| rownames(assay) <- paste0("f",1:nfeat) | |
| colnames(assay) <- paste0("s",1:nsamp) |
This file contains hidden or 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(dplyr) | |
| library(tidyr) | |
| library(purrr) | |
| simulate_genotype <- function(maf, n) rbinom(n, 2, maf) | |
| simulate_data <- function(beta, maf, n) { | |
| data.frame( | |
| genotype = simulate_genotype(maf, n) | |
| ) |> |
This file contains hidden or 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
| > x <- data.frame(seqnames="chr1", start=c(1,101), width=100, foo=c("bar","boo")) |> as_granges() | |
| > x | |
| GRanges object with 2 ranges and 1 metadata column: | |
| seqnames ranges strand | foo | |
| <Rle> <IRanges> <Rle> | <character> | |
| [1] chr1 1-100 * | bar | |
| [2] chr1 101-200 * | boo | |
| ------- | |
| seqinfo: 1 sequence from an unspecified genome; no seqlengths | |
| > x |> tile_ranges(25) |
This file contains hidden or 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
| # Created by chat GPT | |
| # Load necessary libraries | |
| library(splines) | |
| library(GPfit) | |
| # Set seed for reproducibility | |
| set.seed(123) | |
| # Generate non-uniform data |
NewerOlder