Mapping chromatin structure and transactions

Author

Your Name Here

Published

October 21, 2024

bed_intersect() example


Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
x <- tribble(
  ~chrom, ~start, ~end,
  "chr1", 25, 50,
  "chr1", 100, 125
)

y <- tribble(
  ~chrom, ~start, ~end,
  "chr1", 30,     75
)

valr example

You can use read_bed() and related functions to load genome annotations and signals.

snps <- read_bed(
  valr_example("hg19.snps147.chr22.bed.gz"),
  n_fields = 6
)
Warning: The `n_fields` argument of `read_bed()` is deprecated as of valr 0.6.9.
ℹ fields are now determined automatically from the file
genes <- read_bed(
  valr_example("genes.hg19.chr22.bed.gz"),
  n_fields = 6
)

What is in snps and genes?

Interval manipulation

Let’s find and characterize intergenic SNPs. We’ll use the tools bed_substract() and bed_closest(). Take a look and their examples in the documentation to see what they do.

. . .

Take a look at the intergenic and nearby objects in the console.

Interval manipulation

Now that you have overlaps and distances between SNPs and genes, you can go back to dplyr tools to generate reports.

bed_map() example

Copy / paste these into your console.

x <- tribble(
  ~chrom, ~start, ~end,
  "chr1", 100,    250,
  "chr2", 250,    500
)

y <- tribble(
  ~chrom, ~start, ~end, ~value,
  "chr1", 100,    250,  10,
  "chr1", 150,    250,  20,
  "chr2", 250,    500,  500
)

bed_map() example continued

First examine the intersecting intervals.