Browse code

Fix for visualization and vignette adjustments

Christian Arnold authored on 25/04/2022 17:55:56
Showing4 changed files

... ...
@@ -25,7 +25,6 @@ Imports:
25 25
     Matrix,
26 26
     GenomicRanges,
27 27
     RColorBrewer,
28
-    colorspace,
29 28
     ComplexHeatmap,
30 29
     DESeq2,
31 30
     csaw,
... ...
@@ -4208,7 +4208,7 @@ getGRNConnections <- function(GRN, type = "all.filtered",  permuted = FALSE, inc
4208 4208
     "plot_TFPeak_fdr"                = "TF_peak.fdrCurves",
4209 4209
     "plot_TFPeak_fdr_GC"             = "TF_peak.GCCorrection",
4210 4210
     "plot_TFPeak_TFActivity_QC"      = "TF_peak.TFActivity_QC",
4211
-    "plot_class_density"             = "TF_classification_densityPlotsForegroundBackground",
4211
+    "plot_class_density"             = "TF_classification_densityPlots",
4212 4212
     "plot_class_medianClass"         = "TF_classification_stringencyThresholds",
4213 4213
     "plot_class_densityClass"        = "TF_classification_summaryHeatmap",
4214 4214
     "plot_peakGene_diag"             = "peakGene_diagnosticPlots",
... ...
@@ -3772,9 +3772,9 @@ visualizeGRN <- function(GRN, outputFolder = NULL,  basenameOutput = NULL, plotA
3772 3772
         
3773 3773
         
3774 3774
         # Calling plot.new() might be necessary here
3775
-        if(!plotAsPDF){
3776
-            plot.new()
3777
-        }
3775
+        # if(!plotAsPDF){
3776
+        #     #plot.new()
3777
+        # }
3778 3778
         par(mar=c(7,0,0,0) + 0.2)
3779 3779
         
3780 3780
         plot(
... ...
@@ -296,7 +296,7 @@ This function may run a while, and each time-consuming step has a built-in progr
296 296
 For reasons of brevity and organization, we fully describe their interpretation and meaning in detail elsewhere, however. In summary, TF-enhancer diagnostic plots are available for each TF, and each page summarizes the QC for each TF in two plots:  
297 297
 
298 298
 
299
-```{r, echo=FALSE}
299
+```{r, echo=FALSE, include=TRUE, eval = TRUE, class.output="scroll-200", results='hold'}
300 300
 GRN = plotDiagnosticPlots_TFPeaks(GRN, dataType = c("real", "permuted"), plotAsPDF = FALSE, pages = 4)
301 301
 ```
302 302
 
... ...
@@ -338,7 +338,7 @@ For more parameter details, see also the R help (`?AR_classification_wrapper`).
338 338
 
339 339
 After steps that take up a bit of time, it may make sense to store the `GRaNIE` object to disk in order to be able to restore it at any time point. This can simply be done, for example, by saving it as an `rds` file using the built-in function `saveRDS` from R to save our `GRaNIE` object in a compressed rds format.  
340 340
 
341
-```{r saveObject2, echo=TRUE, include=TRUE, eval=FALSE}
341
+```{r saveObject2, echo=TRUE, include=TRUE, eval=FALSE, class.output="scroll-200"}
342 342
 GRN_file_outputRDS = paste0(dir_output, "/GRN.rds")
343 343
 saveRDS(GRN, GRN_file_outputRDS)
344 344
 ```
... ...
@@ -404,7 +404,7 @@ As can be seen from the output, the Pearson correlation for 587 TF-gene pairs ha
404 404
 For more parameter details, see the R help (`?add_TF_gene_correlation`). 
405 405
 
406 406
 Time to save our object again!
407
-```{r saveObject, echo=TRUE, include=TRUE , eval=FALSE}
407
+```{r saveObject, echo=TRUE, include=TRUE , eval=FALSE, class.output="scroll-200"}
408 408
 GRN = deleteIntermediateData(GRN)
409 409
 saveRDS(GRN, GRN_file_outputRDS)
410 410
 ```
... ...
@@ -428,10 +428,9 @@ The table contains many columns, and the prefix of each column name indicates th
428 428
 
429 429
 The `GRaNIE` package also offers a function to visualize a filtered *eGRN* network! It is very easy to invoke, but provides many options to customize the output and the way the graph is drawn. We recommend to explore the options in the R help (`?getGRNConnections`), and here just run the default visualization.
430 430
 
431
-Here, we do not run it, due to some temporary problems causes by RMarkdown. We will update this section as soon as this issue is resolved.
432 431
 
433 432
 ```{r visualizeGRN, echo=TRUE, include=TRUE, eval = TRUE, class.output="scroll-200"}
434
-# GRN = visualizeGRN(GRN, plotAsPDF = FALSE)
433
+GRN = visualizeGRN(GRN, plotAsPDF = FALSE)
435 434
 
436 435
 ```
437 436
 
... ...
@@ -509,7 +508,7 @@ We don't include the output here, but this function runs actually very quickly.
509 508
 
510 509
 Let's, however, check some of the results that are produced! Let's start with checking some general network statistics for the full network. From the various graphs that are produced, we here select only 2 of them for demonstration purposes. First we can check the vertex distribution and gene types for the overall network to get an idea of how the network looks like. Second, we can investigate the most important TFs and genes for the network for both the TF-enhancer-gene as well as TF-gene network. Here, we here show the results for the TF-gene network only:
511 510
 
512
-```{r plotGraphStats, echo=FALSE, fig.cap="<i>General network statistics for the filtered network</i>", out.width = '80%'}
511
+```{r plotGraphStats, echo=FALSE, fig.cap="<i>General network statistics for the filtered network</i>", class.output="scroll-200"}
513 512
 
514 513
 GRN = plotGeneralGraphStats(GRN, plotAsPDF = FALSE, pages = c(1,6))
515 514
 
... ...
@@ -525,7 +524,7 @@ We can also use algorithms for measuring the influence of a node in a network (*
525 524
 
526 525
 Now that we have our eGRN network, we can do various enrichment analyses. Let's start with the most obvious one: Enrichment for the whole network. Again, we are not executing the function here for reasons of time, but you should do so of course when learning how to use the package!
527 526
 
528
-```{r generalEnrichment, echo=FALSE, eval = FALSE}
527
+```{r generalEnrichment, echo=FALSE, eval = FALSE, class.output="scroll-200"}
529 528
 
530 529
 GRN = calculateGeneralEnrichment(GRN, ontology = "GO_BP")
531 530
 
... ...
@@ -533,7 +532,7 @@ GRN = calculateGeneralEnrichment(GRN, ontology = "GO_BP")
533 532
 
534 533
 We can now plot the enrichment for the full graph. In analogy to all the other `plot` functions, a PDF with all enrichment results is produced with the default setting, but by setting `plotAsPDF` to `FALSE`, we can also plot selected results / pages directly to the currently active graphics device. In this case here, as we select only one ontology, there is only one page:
535 534
 
536
-```{r plotGeneralEnrichment, echo=FALSE, fig.cap="<i>General network enrichment for the filtered network</i>", out.width = '80%'}
535
+```{r plotGeneralEnrichment, echo=FALSE, fig.cap="<i>General network enrichment for the filtered network</i>", class.output="scroll-200"}
537 536
 
538 537
 GRN = plotGeneralEnrichment(GRN, plotAsPDF = FALSE, pages = 1)
539 538
 
... ...
@@ -547,7 +546,7 @@ We can see that overall, cell cycle is the term with the most number of genes, a
547 546
 
548 547
 Now, let's check whether we can identify communities within the whole network, along with community-specific enrichments.
549 548
 
550
-```{r communityEnrichment, echo=FALSE}
549
+```{r communityEnrichment, echo=FALSE, class.output="scroll-200"}
551 550
 
552 551
 GRN = calculateCommunitiesStats(GRN)
553 552
 GRN = calculateCommunitiesEnrichment(GRN, ontology = "GO_BP")
... ...
@@ -556,7 +555,7 @@ GRN = calculateCommunitiesEnrichment(GRN, ontology = "GO_BP")
556 555
 
557 556
 These functions may take a while, as enrichment is calculated for each community. Once finished, we are ready to plot the results! First, let's start with some general community statistics:
558 557
 
559
-```{r plotCommunityStats, echo=FALSE, fig.cap="<i>General statistics for the communities from the filtered network</i>", out.width = '80%'}
558
+```{r plotCommunityStats, echo=FALSE, fig.cap="<i>General statistics for the communities from the filtered network</i>", class.output="scroll-200"}
560 559
 
561 560
 GRN = plotCommunitiesStats(GRN, plotAsPDF = FALSE, pages = c(1,3))
562 561
 
... ...
@@ -566,7 +565,7 @@ First, we see an overview across all communities and their network sizes, and wh
566 565
 
567 566
 Next, let's plot the community-specific enrichment:
568 567
 
569
-```{r plotCommunityEnrichment, echo=FALSE, fig.cap="<i>Community enrichment for 3 different communities</i>", out.width = '80%'}
568
+```{r plotCommunityEnrichment, echo=FALSE, fig.cap="<i>Community enrichment for 3 different communities</i>", class.output="scroll-200"}
570 569
 
571 570
 GRN = plotCommunitiesEnrichment(GRN, plotAsPDF = FALSE, pages = c(1,2,3))
572 571
 
... ...
@@ -576,7 +575,7 @@ GRN = plotCommunitiesEnrichment(GRN, plotAsPDF = FALSE, pages = c(1,2,3))
576 575
 We also provide an overview across the whole network and all communities that lists all the enriched terms that appear in at least one enrichment analysis, so a direct comparison of the specificity and commonalities across communities and between the general network and any community is facilitated. This also shows that some terms, here more than with a full dataset, are only identified as being enriched for the full network but not within any of the communities individually. We offer this function for all terms as well as only the top 10 enriched terms per community, and we here show only the filtered version due to reasons of brevity:
577 576
 
578 577
 
579
-```{r plotCommunityEnrichment2, echo=FALSE, fig.cap="<i>Summary of the community enrichment</i>", out.width = '80%'}
578
+```{r plotCommunityEnrichment2, echo=FALSE, fig.cap="<i>Summary of the community enrichment</i>", class.output="scroll-200"}
580 579
 
581 580
 GRN = plotCommunitiesEnrichment(GRN, plotAsPDF = FALSE, pages = c(5))
582 581
 
... ...
@@ -588,7 +587,7 @@ GRN = plotCommunitiesEnrichment(GRN, plotAsPDF = FALSE, pages = c(5))
588 587
 
589 588
 In analogy to community enrichment, we can also calculate enrichment based on TFs via their target genes they are connected to. Running a TF enrichment analyses is straight forward, with the parameter `n` we can control the number of TFs to run the enrichment for - the function runs the enrichment for the top connected TFs. Thus, `n=3` equals running the enrichment for the top 3 connected TFs. Here, we show the results for one of the TFs, *EGR1.0.A*, as well as a summary across all top 3 connected TFs, in analogy the results for the community enrichment.
590 589
 
591
-```{r TFEnrichment, echo=FALSE, fig.cap="<i>Enrichment summary for TFs</i>", out.width = '100%'}
590
+```{r TFEnrichment, echo=FALSE, fig.cap="<i>Enrichment summary for TFs</i>", class.output="scroll-200"}
592 591
 GRN = plotTFEnrichment(GRN, plotAsPDF = FALSE, n = 3, pages = c(1,5))
593 592
 ```
594 593
 
... ...
@@ -598,7 +597,7 @@ GRN = plotTFEnrichment(GRN, plotAsPDF = FALSE, n = 3, pages = c(1,5))
598 597
 
599 598
 We are now finished with the main workflow, all that is left to do is to save our `GRaNIE` object to disk so we can load it at a later time point without having to repeat the analysis. We recommend to run the convenience function `deleteIntermediateData()` beforehand that aims to reduce its size by deleting some intermediate data that may still be stored within the object. For more parameter details, see the R help (`?deleteIntermediateData`).  Finally, as we did already in the middle of the workflow, we save the object finally in rds format.
600 599
 
601
-```{r saveObject3, echo=TRUE, include=TRUE, eval=FALSE}
600
+```{r saveObject3, echo=TRUE, include=TRUE, eval=FALSE, class.output="scroll-200"}
602 601
 GRN = deleteIntermediateData(GRN)
603 602
 saveRDS(GRN, GRN_file_outputRDS)
604 603
 ```