Entering edit mode
2.2 years ago
storm1907
▴
30
Hello, I have a probem when converting bedgraph files to Granges list
I use this R script:
library("GenomicRanges")
bg_files <- c("file1.bedgraph", "file2.bedgrah")
bgs <- lapply(bg_files, function(x) {
bg <- read.table(x, sep="\t", skip=1)
colnames(bg) <- c("seqnames", "start", "end", "value")
gr <- makeGRangesFromDataFrame(bg, ignore.strand=TRUE, keep.extra.columns=TRUE)
return(gr)
})
# Convert the list of GRanges into a GRangesList.
gr_list <- GRangesList(bgs)
However, the output is a dataframe. The downstream software does not accept dataframes, only numeric vectors:
if (!(is.numeric(seg) || is.data.frame(seg))) {
stop("Wrong representation of segments.")
}
if (is.vector(seg))
seg = t(seg)
How could I get Grange list from bedgraph files in vector format?
Thank you!
What downstream software and function are you trying to use? A GRanges list and a numeric vector are two very different data types.
rpolicastro I am trying to run CINdex from exome data: https://bioconductor.org/packages/release/bioc/html/CINdex.html
Here is the full function: https://rdrr.io/bioc/CINdex/src/R/segments.to.profile.R
I am not familiar with the package, but the How to obtain Cytoband and Stain Information and Prepare input data for CINdex documents didn't help?
Have you already tried to replace the convenience function
makeGRangesFromDataFrame()
with a manually constructed GRanges object?Also, it could be related to this statement in the manual?
Thank you for your reply!
in CIndex package, nothing much was told about sample data preparation, only "The result of any segmentation algorithm such as CBS,FMR. Should be a data frame of 3 column-lists or matrix of three-column lists; Grange list"
I have vcf, bam and bedgraph files available. I tried to make grange list from vcf and failed; now I was suggested to use this custom script to make grange list from bedgraph, and result is also not accepted by CINdex
Thank for this function:
I tried, but keep getting errors, how do I prepare bg variable in this case?
Then please copy and paste the error message(s) here, so we can help. The output or an excerpt of the output from
str(bg)
might be useful for that as well.The CIndex package does have info on sample data preparation. I was referring to the documents, that I already linked above: How To Download Cytoband Info and Prepare Input Data.
Hello!
the manual was suitable for preparing probe annotation, reference and clinical data files; However, I could not use it for sample file preparation (2.1. Segment data), as the example only says "The CINdex package can accept output from ANY segmentation alggorithm, as long as the data are in the form of a GRangesList object", but does not demonstrate, how to obtain it from bam or vcf, or bedgraph file, which are available for me
THe error is following: