Skip to content

Commit c0312f6

Browse files
authored
Merge pull request #54 from c-mertes/fraser2
Fraser2
2 parents 3cec0ce + eb51f7f commit c0312f6

5 files changed

Lines changed: 30 additions & 32 deletions

File tree

R/AllGenerics.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ FRASER.results <- function(object, sampleIDs, fdrCutoff,
788788
deltaPsiVals <- deltaPsiValue(tmp_x, type)
789789
rho <- rho(tmp_x, type)
790790
aberrant <- aberrant.FRASER(tmp_x, type=type,
791-
padjCutoff=fdrCutoff,
791+
padjCutoff=ifelse(isTRUE(aggregate),
792+
NA, fdrCutoff),
792793
deltaPsiCutoff=dPsiCutoff,
793794
minCount=minCount,
794795
rhoCutoff=rhoCutoff,
@@ -1080,6 +1081,10 @@ aberrant.FRASER <- function(object, type=fitMetrics(object),
10801081
if(is.na(padjCutoff)){
10811082
padjCutoff <- 1
10821083
}
1084+
if(isTRUE(aggregate)){
1085+
padjCutoffGene <- padjCutoff
1086+
padjCutoff <- 1
1087+
}
10831088

10841089
if(isTRUE(all)){
10851090
aberrantEvents <- matrix(TRUE, nrow=nrow(object), ncol=ncol(object))
@@ -1121,7 +1126,7 @@ aberrant.FRASER <- function(object, type=fitMetrics(object),
11211126
if(isFALSE(all)){
11221127
aberrantEvents <- aberrantEvents & as.matrix(
11231128
padj_gene[rownames(aberrantEvents),colnames(aberrantEvents)]
1124-
) <= padjCutoff
1129+
) <= padjCutoffGene
11251130
}
11261131
}
11271132

R/getNSetterFuns.R

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -748,16 +748,18 @@ getPlottingDT <- function(fds, axis=c("row", "col"), type=currentType(fds),
748748
)
749749
dt[, deltaPsi:=obsPsi - predPsi]
750750

751-
# add aberrant information to it
752-
aberrantVec <- aberrant(fds, ..., padjVals=dt[,.(padj)],
753-
dPsi=dt[,.(deltaPsi)], n=dt[,.(n)],
754-
rhoVals=dt[,.(rho)], aggregate=FALSE)
755-
dt[,aberrant:=aberrantVec]
756-
757751
# if requested return gene p values
758752
if(isTRUE(aggregate)){
759-
dt <- dt[!is.na(featureID)]
753+
# get gene-level aberrant status
754+
aberrantGeneLevel <- aberrant(fds[, idxcol], ..., aggregate=TRUE)
755+
aberrantGeneLevel <- melt(
756+
data.table(featureID=rownames(aberrantGeneLevel),
757+
aberrantGeneLevel),
758+
value.name="aberrant", id.vars="featureID",
759+
variable.name="sampleID")
760+
760761
# split featureID into several rows if more than one
762+
dt <- dt[!is.na(featureID)]
761763
dt[, dt_idx:=seq_len(.N)]
762764
dt_tmp <- dt[, splitGenes(featureID), by="dt_idx"]
763765
dt <- dt[dt_tmp$dt_idx,]
@@ -780,6 +782,10 @@ getPlottingDT <- function(fds, axis=c("row", "col"), type=currentType(fds),
780782
pvalsGene <- merge(pvalsGene[[1]], pvalsGene[[2]],
781783
by=c("featureID", "sampleID"))
782784

785+
# merge with gene level aberrant status
786+
pvalsGene <- merge(pvalsGene, aberrantGeneLevel,
787+
by=c("featureID", "sampleID"))
788+
783789
# merge with gene pval matrix
784790
dt <- merge(dt, pvalsGene, by=c("featureID", "sampleID"))
785791
dt[,`:=`(pval=gene_pval, padj=gene_padj,
@@ -789,6 +795,12 @@ getPlottingDT <- function(fds, axis=c("row", "col"), type=currentType(fds),
789795
dt <- dt[order(sampleID, featureID, type, -aberrant,
790796
padj, -abs(deltaPsi))][
791797
!duplicated(data.table(sampleID, featureID, type))]
798+
} else{
799+
# add aberrant information to it
800+
aberrantVec <- aberrant(fds, ..., padjVals=dt[,.(padj)],
801+
dPsi=dt[,.(deltaPsi)], n=dt[,.(n)],
802+
rhoVals=dt[,.(rho)], aggregate=FALSE)
803+
dt[,aberrant:=aberrantVec]
792804
}
793805

794806
# return object

R/mergeExternalData.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ mergeExternalData <- function(fds, countFiles, sampleIDs, annotation=NULL){
100100
# merge psi5/psi3 data
101101
#
102102
extractExtData <- function(fds, countFun, type, ov, extData, extName){
103-
ctsOri <- as.matrix(countFun(fds, type=type)[from(ov),])
104-
ctsExt <- as.matrix(mcols(extData[[extName]])[to(ov),])
103+
ctsOri <- as.matrix(countFun(fds, type=type)[from(ov),,drop=FALSE])
104+
ctsExt <- as.matrix(mcols(extData[[extName]])[to(ov),,drop=FALSE])
105105
ans <- cbind(ctsOri, ctsExt)
106106
mode(ans) <- "integer"
107107
ans

R/plotMethods.R

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -337,25 +337,6 @@ plotVolcano.FRASER <- function(object, sampleID,
337337
theme(legend.position="none") +
338338
scale_color_manual(values=c("gray40", "firebrick"))
339339

340-
if(!is.na(deltaPsiCutoff)){
341-
g <- g +
342-
geom_vline(xintercept=c(-deltaPsiCutoff, deltaPsiCutoff),
343-
color="firebrick", linetype=2)
344-
}
345-
346-
if(!is.na(padjCutoff)){
347-
if(dt[padj <= padjCutoff, .N] > 0){
348-
padj_line <- min(dt[padj <= padjCutoff, -log10(pval)])
349-
padj_line <- min(dt[padj <= padjCutoff, -log10(pval)])
350-
}
351-
if(!"padj_line" %in% ls() || padj_line > 10 || is.na(padj_line)){
352-
padj_line <- 6
353-
}
354-
g <- g +
355-
geom_hline(yintercept=padj_line, color="firebrick", linetype=4)
356-
}
357-
358-
359340
if(isFALSE(basePlot)){
360341
g <- g + xlab(paste("delta",
361342
ggplotLabelPsi(type, asCharacter=TRUE)[[1]])) +

man/results.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)