keep chromosome names in a bigwig file
0
0
Entering edit mode
21 months ago
Assa Yeroslaviz ★ 1.5k

after an update of the rtracklyer package, I loose the names of chromosomes in my bigwigfile object.

I have a list of bigwig files, I'm reading into R for processing.

filesList <- list.files(path = "./bigWigFiles",pattern = ".bw", full.names = TRUE)
bigWigList <- lapply(X = filesList, FUN = import.bw, as="NumericList")

In rtracklayer version 1.38.3 the objkect has the names of the chromosome in a list

    > str(bigWigList[[1]])
Formal class 'SimpleNumericList' [package "IRanges"] with 4 slots
  ..@ elementType    : chr "numeric"
  ..@ elementMetadata: NULL
  ..@ metadata       :List of 1
  .. ..$ ranges:Formal class 'GRanges' [package "GenomicRanges"] with 6 slots
  .. .. .. ..@ seqnames       :Formal class 'Rle' [package "S4Vectors"] with 4 slots
  .. .. .. .. .. ..@ values         : Factor w/ 17 levels "chrI","chrII",..: 1 2 3 4 5 6 7 8 9 10 ...
  .. .. .. .. .. ..@ lengths        : int [1:17] 1 1 1 1 1 1 1 1 1 1 ...
  .. .. .. .. .. ..@ elementMetadata: NULL
  .. .. .. .. .. ..@ metadata       : list()
  .. .. .. ..@ ranges         :Formal class 'IRanges' [package "IRanges"] with 6 slots
  ...
  .. .. .. ..@ seqinfo        :Formal class 'Seqinfo' [package "GenomeInfoDb"] with 4 slots
  .. .. .. .. .. ..@ seqnames   : chr [1:17] "chrI" "chrII" "chrIII" "chrIV" ...
  .. .. .. .. .. ..@ seqlengths : int [1:17] NA NA NA NA NA NA NA NA NA NA ...
  .. .. .. .. .. ..@ is_circular: logi [1:17] NA NA NA NA NA NA ...
  .. .. .. .. .. ..@ genome     : chr [1:17] NA NA NA NA ...
  .. .. .. ..@ metadata       : list()
  ..@ listData       :List of 17
  .. ..$ chrI   : num [1:230218] 0 1 1 1 1 2 4 6 8 10 ...
  .. ..$ chrII  : num [1:813184] 8 14 24 30 37 44 56 58 64 67 ...
  .. ..$ chrIII : num [1:316620] 1 4 5 7 7 10 11 10 15 18 ...
  .. ..$ chrIV  : num [1:1531933] 7 7 15 17 20 22 24 30 34 37 ...
  .. ..$ chrIX  : num [1:439888] 15 42 69 87 98 111 127 146 161 185 ...
  .. ..$ chrV   : num [1:576874] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ chrVI  : num [1:270161] 0 3 3 4 6 8 10 11 11 11 ...
  .. ..$ chrVII : num [1:1090940] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ chrVIII: num [1:562643] 4 4 4 4 4 4 4 4 4 4 ...
  .. ..$ chrX   : num [1:745751] 16 42 55 70 82 102 114 120 132 142 ...
  .. ..$ chrXI  : num [1:666816] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ chrXII : num [1:1078177] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ chrXIII: num [1:924431] 0 1 1 1 1 1 1 1 1 1 ...
  .. ..$ chrXIV : num [1:784333] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ chrXV  : num [1:1091291] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ chrXVI : num [1:948066] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ chrmt  : num [1:85779] 33 52 70 71 73 80 83 84 85 87 ...

But in a different session with rtracklayer version 1.44.0 I don't have them anymore.

 str(bigWigList[[1]])
Formal class 'SimpleNumericList' [package "IRanges"] with 4 slots
  ..@ elementType    : chr "numeric"
  ..@ elementMetadata: NULL
  ..@ metadata       :List of 1
  .. ..$ ranges:Formal class 'GRanges' [package "GenomicRanges"] with 7 slots
  .. .. .. ..@ seqnames       :Formal class 'Rle' [package "S4Vectors"] with 4 slots
  .. .. .. .. .. ..@ values         : Factor w/ 17 levels "chrI","chrII",..: 1 2 3 4 5 6 7 8 9 10 ...
  .. .. .. .. .. ..@ lengths        : int [1:17] 1 1 1 1 1 1 1 1 1 1 ...
  .. .. .. .. .. ..@ elementMetadata: NULL
  .. .. .. .. .. ..@ metadata       : list()
  .. .. .. ..@ ranges         :Formal class 'IRanges' [package "IRanges"] with 6 slots
  ...
  .. .. .. .. .. ..@ seqnames   : chr [1:17] "chrI" "chrII" "chrIII" "chrIV" ...
  .. .. .. .. .. ..@ seqlengths : int [1:17] NA NA NA NA NA NA NA NA NA NA ...
  .. .. .. .. .. ..@ is_circular: logi [1:17] NA NA NA NA NA NA ...
  .. .. .. .. .. ..@ genome     : chr [1:17] NA NA NA NA ...
  .. .. .. ..@ elementMetadata:Formal class 'DataFrame' [package "S4Vectors"] with 6 slots
  .. .. .. .. .. ..@ rownames       : NULL
  .. .. .. .. .. ..@ nrows          : int 17
  .. .. .. .. .. ..@ listData       : Named list()
  .. .. .. .. .. ..@ elementType    : chr "ANY"
  .. .. .. .. .. ..@ elementMetadata: NULL
  .. .. .. .. .. ..@ metadata       : list()
  .. .. .. ..@ elementType    : chr "ANY"
  .. .. .. ..@ metadata       : list()
  ..@ listData       :List of 17
  .. ..$ : num [1:230218] 0 1 1 1 1 2 4 6 8 10 ...
  .. ..$ : num [1:813184] 8 14 24 30 37 44 56 58 64 67 ...
  .. ..$ : num [1:316620] 1 4 5 7 7 10 11 10 15 18 ...
  .. ..$ : num [1:1531933] 7 7 15 17 20 22 24 30 34 37 ...
  .. ..$ : num [1:439888] 15 42 69 87 98 111 127 146 161 185 ...
  .. ..$ : num [1:576874] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ : num [1:270161] 0 3 3 4 6 8 10 11 11 11 ...
  .. ..$ : num [1:1090940] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ : num [1:562643] 4 4 4 4 4 4 4 4 4 4 ...
  .. ..$ : num [1:745751] 16 42 55 70 82 102 114 120 132 142 ...
  .. ..$ : num [1:666816] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ : num [1:1078177] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ : num [1:924431] 0 1 1 1 1 1 1 1 1 1 ...
  .. ..$ : num [1:784333] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ : num [1:1091291] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ : num [1:948066] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ : num [1:85779] 33 52 70 71 73 80 83 84 85 87 ...

For both versions I'm using the exact same command with the exact same bigwig file. Any idea what was changed, or how I can get the chromosome names into the output?

thanks Assa

rtracklayer import.bw bigwig • 471 views
ADD COMMENT
0
Entering edit mode

I have figured out I can get them by calling them as such

   > levels(bigWigList[[1]]@metadata$ranges@seqnames)
 [1] "chrI"    "chrII"   "chrIII"  "chrIV"   "chrIX"   "chrV"    "chrVI"  
 [8] "chrVII"  "chrVIII" "chrX"    "chrXI"   "chrXII"  "chrXIII" "chrXIV" 
[15] "chrXV"   "chrXVI"  "chrmt"

But this looks a bit extreme. Is there a better way?

ADD REPLY
0
Entering edit mode

I think a better way to access them, instead of using slots directly, would be

as.character(seqnames(metadata(bigWigList[[1]])$ranges))
ADD REPLY
0
Entering edit mode

thanks for the suggestion. IMHO this is also not really a fixed solution, but just a different way to dodge the problem.

Previously it was possible to access them using the command names(bigWigList[[1]]) because they were saved with the data.

ADD REPLY
0
Entering edit mode

If you were able to access them previously, it might be worth starting a discussion with the developers on their recommended forum (mostly a GitHub issue here). It seems their listData slot has gone from being a named list to an unnamed list.

ADD REPLY

Login before adding your answer.

Traffic: 2251 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6