R/loadData.R

Defines functions loadData

loadData <- function(analysis){
  if (class(analysis) == 'Binalysis') {
    ld <- '

```{r loadData,echo=FALSE}
binalysis <- read_rds("reportData.rds")
```

'
  }
  if (class(analysis) == 'Analysis') {
    ld <- '

```{r loadData,echo=FALSE}
analysis <- read_rds("reportData.rds")
```

'
  }
  if (class(analysis) == 'MetaboProfile') {
    ld <- '

```{r loadData,echo=FALSE}
processed <- read_rds("reportData.rds")
```

'
  }
  if (class(analysis) == 'Workflow') {
    if (T %in% (c('peakPick','spectralBin') %in% analysis@flags)) {
      
      if ({analysis %>%
          resultsProcessing() %>%
          class()} == 'Binalysis') {
        pr <- '
binalysis <- workflowData %>%
                        resultsProcessing()' 
      }
      
      if ({analysis %>%
          resultsProcessing() %>%
          class()} == 'MetaboProfile') {
        pr <- '
processed <- workflowData %>%
                        resultsProcessing()' 
      } 
    } else {
      pr <- ''
    }
    
    
    if ('preTreat' %in% analysis@flags) {
      ar <- '
analysis <- workflowData %>%
                        resultsAnalysis()'
    } else {
      ar <- ''
    }
    
    
    if ('MFassignment' %in% analysis@flags) {
      anr <- '
assignment <- workflowData %>%
      resultsAnnotation()'
    } else {
      anr <- ''
    }
    
    
    
    ld <- str_c('

```{r loadData,echo=FALSE}
workflowData <- read_rds("reportData.rds")',
                pr,ar,anr,
                '
```
    
')
  }
  if (class(analysis) == 'Assignment') {
    ld <- '

```{r loadData,echo=FALSE}
assignment <- read_rds("reportData.rds")
```

'
  }
  return(ld)
}
jasenfinch/metaboReports documentation built on Nov. 19, 2021, 7:23 p.m.