Entering edit mode
Hello,
I have a dataframe df1 and a grange object gr. The rownames
respectively
names (gr) are identical but not necessary in the same order. I wish
to
append df1 as metadata to the gr (of course rownames (df) and names
(gr)
must fit).
Could you please give me a hint.
Thanks
Hermann
> df1
Strand A1 A2
rs3737728 u C T
rs6687776 u C T
rs9651273 u G A
> gr
GRanges with 3 ranges and 1 metadata column:
seqnames ranges strand | score
<rle> <iranges> <rle> | <character>
rs3737728 chr1 [1021415, 1021415] * | 0.340955
rs6687776 chr1 [1030565, 1030565] * | 0.438123
rs9651273 chr1 [1031540, 1031540] * | 0.196662
---
seqlengths:
chr1 chr10 ... chrX chrY
NA NA ... NA NA
> dput (df1)
structure(list(Strand = structure(c(1L, 1L, 1L), .Label = "u", class =
"factor"),
A1 = structure(c(2L, 2L, 3L), .Label = c("A", "C", "G", "T"
), class = "factor"), A2 = structure(c(4L, 4L, 1L), .Label =
c("A",
"C", "G", "T"), class = "factor")), .Names = c("Strand",
"A1", "A2"), class = "data.frame", row.names = c("rs3737728",
"rs6687776", "rs9651273"))
> dput (gr)
new("GRanges"
, seqnames = new("Rle"
, values = structure(1L, .Label = c("chr1", "chr10", "chr11",
"chr12",
"chr13",
"chr14", "chr15", "chr16", "chr17", "chr17_ctg5_hap1", "chr18",
"chr19", "chr2", "chr20", "chr21", "chr22", "chr3", "chr4",
"chr4_ctg9_hap1",
"chr5", "chr6", "chr6_apd_hap1", "chr6_cox_hap2", "chr6_dbb_hap3",
"chr6_mann_hap4", "chr6_mcf_hap5", "chr6_qbl_hap6", "chr6_ssto_hap7",
"chr7", "chr8", "chr9", "chrM", "chrX", "chrY"), class = "factor")
, lengths = 3L
, elementMetadata = NULL
, metadata = list()
)
, ranges = new("IRanges"
, start = c(1021415L, 1030565L, 1031540L)
, width = c(1L, 1L, 1L)
, NAMES = c("rs3737728", "rs6687776", "rs9651273")
, elementType = "integer"
, elementMetadata = NULL
, metadata = list()
)
, strand = new("Rle"
, values = structure(3L, .Label = c("+", "-", "*"), class =
"factor")
, lengths = 3L
, elementMetadata = NULL
, metadata = list()
)
, elementMetadata = new("DataFrame"
, rownames = NULL
, nrows = 3L
, listData = structure(list(score = c("0.340955", "0.438123",
"0.196662")), .Names = "score")
, elementType = "ANY"
, elementMetadata = NULL
, metadata = list()
)
, seqinfo = new("Seqinfo"
, seqnames = c("chr1", "chr10", "chr11", "chr12", "chr13",
"chr14",
"chr15",
"chr16", "chr17", "chr17_ctg5_hap1", "chr18", "chr19", "chr2",
"chr20", "chr21", "chr22", "chr3", "chr4", "chr4_ctg9_hap1",
"chr5", "chr6", "chr6_apd_hap1", "chr6_cox_hap2", "chr6_dbb_hap3",
"chr6_mann_hap4", "chr6_mcf_hap5", "chr6_qbl_hap6", "chr6_ssto_hap7",
"chr7", "chr8", "chr9", "chrM", "chrX", "chrY")
, seqlengths = c(NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_)
, is_circular = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA,
NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA)
, genome = c("hg19", "hg19", "hg19", "hg19", "hg19", "hg19",
"hg19",
"hg19",
"hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19",
"hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19",
"hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19",
"hg19", "hg19")
)
, metadata = list(<s4 object="" of="" class="" structure("dataframe",="" package="IRanges" )="">)
)
>
[[alternative HTML version deleted]]