Skip to content

Commit c928492

Browse files
author
c.lareau
committed
fixed row.names when subsetting the data.frame
From: Caleb Lareau <lareauc@Calebs-MacBook-Pro.local> git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/diffloop@117023 bc3139a8-67e5-0310-9ffc-ced21a209358
1 parent e003ff8 commit c928492

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

R/annotation.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ setMethod(f = "getHumanTSS", signature = c("character", "ANY"),
215215

216216
#' Annotate loops as Enhancer-Promoter or CTCF-CTCF
217217
#'
218-
#' \code{annotateLoops} adds a column to the results slot of a loops
218+
#' \code{annotateLoops} adds a column to the rowData slot of a loops
219219
#' object categorizing loops as either e-p (enhancer-promoter), ctcf
220220
#' (CTCF-CTCF) or none (no biological annotation). If both ctcf and e-p,
221221
#' then categorized as e-p.
@@ -231,7 +231,7 @@ setMethod(f = "getHumanTSS", signature = c("character", "ANY"),
231231
#' @param enhancer GRanges object corresponding to locations of enhancer peaks
232232
#' @param promoter GRanges object corresponding to locations of promoter regions
233233
#'
234-
#' @return A loops object with an additional row 'loop.type' in the results slot
234+
#' @return A loops object with an additional row 'loop.type' in the rowData slot
235235
#'
236236
#' @examples
237237
#' rda<-paste(system.file('rda',package='diffloop'),'loops.small.rda',sep='/')

R/core.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ setMethod(f = "subsetRegion", signature = c("loops", "GRanges",
270270
intsdf <- as.data.frame(dlo@interactions)
271271

272272
# Update interactions indices
273-
lm <- mapping[match(intsdf$left, mapping$queryHits), 2, drop=F]
274-
rm <- mapping[match(intsdf$right,mapping$queryHits), 2, drop=F]
273+
lm <- mapping[match(intsdf$left, mapping$queryHits), 2, drop=FALSE]
274+
rm <- mapping[match(intsdf$right,mapping$queryHits), 2, drop=FALSE]
275275

276276
# Format new indices matrix
277277
totalupdate <- cbind(unlist(lm), unlist(rm))
@@ -282,15 +282,15 @@ setMethod(f = "subsetRegion", signature = c("loops", "GRanges",
282282
# Subset rowData
283283
newRowData <- as.data.frame(dlo@rowData[cc, ])
284284
colnames(newRowData) <- colnames(dlo@rowData)
285+
row.names(newRowData) <- NULL
285286

286287
# Grab counts indicies; removes lines that don't map to
287288
# anything via making them NAs and then removing them
288289
newcounts <- matrix(dlo@counts[cc], ncol = ncol(dlo@counts))
289290
colnames(newcounts) <- colnames(dlo@counts)
290291

291292
# Update values
292-
slot(dlo, "anchors", check = TRUE) <- dlo@anchors[keepTheseAnchors,
293-
]
293+
slot(dlo, "anchors", check = TRUE) <- dlo@anchors[keepTheseAnchors, ]
294294
slot(dlo, "interactions", check = TRUE) <- newinteractions
295295
slot(dlo, "counts", check = TRUE) <- newcounts
296296
slot(dlo, "rowData", check = TRUE) <- newRowData
@@ -306,8 +306,8 @@ setMethod(f = "subsetRegion", signature = c("loops", "GRanges",
306306
intsdf <- as.data.frame(dlo@interactions)
307307

308308
# Update interaction indicies
309-
lm <- mapping[match(intsdf$left, mapping$queryHits), 2, drop=F]
310-
rm <- mapping[match(intsdf$right,mapping$queryHits), 2, drop=F]
309+
lm <- mapping[match(intsdf$left, mapping$queryHits), 2, drop=FALSE]
310+
rm <- mapping[match(intsdf$right,mapping$queryHits), 2, drop=FALSE]
311311

312312
# Format new indices matrix
313313
totalupdate <- cbind(unlist(lm), unlist(rm))
@@ -323,6 +323,8 @@ setMethod(f = "subsetRegion", signature = c("loops", "GRanges",
323323
# Subset rowData
324324
newRowData <- as.data.frame(dlo@rowData[cc, ])
325325
colnames(newRowData) <- colnames(dlo@rowData)
326+
row.names(newRowData) <- NULL
327+
326328

327329
# Update values
328330
slot(dlo, "anchors", check = TRUE) <- newAnchors

man/annotateLoops.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)