Skip to content

Instantly share code, notes, and snippets.

@Nanguage
Last active September 21, 2021 02:40
Show Gist options
  • Save Nanguage/9b2b089b8721cc05d669a1230c90282c to your computer and use it in GitHub Desktop.
Save Nanguage/9b2b089b8721cc05d669a1230c90282c to your computer and use it in GitHub Desktop.
library(GenomicRanges)
library(ggbio)
pairs.df <- read.table("D:/tmp/ggbio_demo/ZQL-49_final.txt",header=FALSE, sep="\t")[,1:7]
colnames(pairs.df) <- c("read", "chr1", "pos1", "chr2", "pos2", "strand1", "strand2")
chromsize.df <- read.csv("D:/tmp/ggbio_demo/susScr11_ASFV_noun.fa.csv")
chromsize.gr <- GRanges(
seqnames = chromsize.df$seqnames,
ranges = IRanges(start=1, end=chromsize.df$end),
)
seqlengths(chromsize.gr) <- chromsize.df$width
pairs.gr <- GRanges(
seqnames = pairs.df$chr1,
ranges = IRanges(start=pairs.df$pos1, end=pairs.df$pos1),
seqlengths = seqlengths(chromsize.gr),
to.gr = GRanges(
seqnames=pairs.df$chr2,
ranges=IRanges(start=pairs.df$pos2, end=pairs.df$pos2),
seqlengths = seqlengths(chromsize.gr)),
)
p <- ggbio() +
circle(chromsize.gr, geom="ideo", fill="gray70") +
circle(chromsize.gr, geom="scale", size=2) +
circle(chromsize.gr, geom="text", aes(label=seqnames), vjust=0, size=3) +
circle(pairs.gr, geom="link", linked.to="to.gr", radius=30, aes(color=seqnames))
p
@Nanguage
Copy link
Author

GRanges object should specify the seqlengths attribute when plot the "link" geom.

@Nanguage
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment