Skip to content

Instantly share code, notes, and snippets.

@vjcitn
Created August 31, 2024 17:05
Show Gist options
  • Save vjcitn/6af2e5ed69e0184cdd4adec9794c7b67 to your computer and use it in GitHub Desktop.
Save vjcitn/6af2e5ed69e0184cdd4adec9794c7b67 to your computer and use it in GitHub Desktop.
library(plotly)
library(ggplot2)
library(XenSCE)
if (!exists("gbm")) load("gbm.rda")
plotly_seg = function(xsce, xlim=c(5800,6000), ylim=c(6300, 6500), show_tx=TRUE) {
bounds = getCellBoundaries(xsce)
bounds = bounds[bounds$vertex_x > xlim[1] &
bounds$vertex_x < xlim[2] & bounds$vertex_y > ylim[1] & bounds$vertex_y < ylim[2],]
c4 <- as.data.frame(bounds)
#ggplot(c4, aes(x=vertex_x, y=vertex_y, group=cell_id)) + geom_path() -> pas
tx = getTranscripts(xsce)
# tx[which(as.character(tx$cell_id) %in% unique(c4$cell_id)),] -> myt
myt = tx[tx$x_location > xlim[1] & tx$x_location < xlim[2] &
tx$y_location > ylim[1] & tx$y_location < ylim[2], ]
ggplot(c4, aes(x=vertex_x, y=vertex_y, group=cell_id)) + geom_path() + geom_point(data=myt, aes(x=x_location, y=y_location, text=as.character(feature_name)), size=.05, colour="grey", alpha=.2) -> uu
ggplotly(uu)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment