Cannot put file path in for bam file when attempting to construct a TDS in transcriptR
1
0
Entering edit mode
@jasonwilliams-21306
Last seen 4.7 years ago

Hi,

I am following this vignette to use transcriptR to combine RNASeq and ChIPSeq data.

https://bioconductor.org/packages/release/bioc/vignettes/transcriptR/inst/doc/transcriptR.pdf

Unfortunately I'm falling at the first hurdle - as when I am trying to insert the path to bam file for my RNASeq files follwing the Vignette - the script is not expecting a file path, but instead, "known genes". When I try to put the file path in anyway, I get an

Error: unexpected '/' in "tds <- constructTDS(~/"

I loaded the libraries and installed transcriptR successfully before this following the script in the same vignette.

Any help would be appreciated.

Best,

Jason

transcriptR • 1.0k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 11 hours ago
United States

It would be helpful if you provided more of your code, as you leave us to guessing as to what you might have done. But do note that the file path has to be character, and from your error it appears that it might not have been character, as I don't see a quote there. In addition,

> read.table(~/)
Error: unexpected '/' in "read.table(~/"

I get the same error if I do what I think you did (note that at this point the function call is irrelevant).

ADD COMMENT
0
Entering edit mode

Hi James,

Thanks for your help.

Here's the whole code from the r markdown I started to make.

title: "trasncriptR"
author: "Jason"
date: "17/10/2019"
output: html_document
---

```{r download transcriptR}
if (!requireNamespace("BiocManager", quietly=TRUE))+     install.packages("BiocManager")> BiocManager::install("transcriptR")
```

```{r install packages and libraries required for transcriptR}
library(GenomicFeatures)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
#knownGene <- TxDb.Hsapiens.UCSC.hg19.knownGene
#Extract genes information> knownGene.genes <- genes(knownGene)
```

```{r transcriptionDataSet object construction}

```{r transcriptionDataSet object construction}
tds <- constructTDS(data/Continuum_ChIPSeq/Continuum_DiffBind/RNASeq_i7Aligned.out.bam, region, fragment.size = 250, unique = FALSE, paired.end = FALSE, swap.strand = TRUE)
#file                 A path to a BAM file with sequencing reads.
#region               GRanges. Genomic region(s) to extract reads from. If not supplied, all the reads
#                     from a BAM file are extracted.
#fragment.size           Numeric. Extend read length to the fragment size. Default: 250.
#unique                 Logical. Whether to remove duplicated reads (based on the genomic coordinates).                               Default: FALSE.
#paired.end              Logical. Whether to treat a BAM file as paired-end.  Default: FALSE.
#swap.strand Logical.    Whether to reverse the strand of the read. Default: FALSE.
#param                  ScanBamParam object influencing what fields and which records (reads) are im-
#ported                 from a BAM file. Default: NULL.

```
Error in constructTDS(data/Continuum_ChIPSeq/Continuum_DiffBind/RNASeq_i7Aligned.out.bam,  : 
  could not find function "constructTDS"

Even though I pasted the code from the vignette above, it is not expecting a file path, usually you can tab complete a file path when it does if you see what I mean. It obviously has something to do with the fact that it cannot find the constructTDS function....as I just followed the vignette I don't know what else to try.

Best wishes,

Jason

ADD REPLY
0
Entering edit mode

The actual code from the vignette goes like this:

># or initialize a new one (do not run the following code)
># specify a region of interest (optional)
> region <- GRanges(seqnames = "chr15", ranges = IRanges(start = 63260000, end = 63300000))
># object construction
> tds <- constructTDS(file = path.to.Bam, 
                      region = region, 
                      fragment.size = 250,
                      unique = FALSE, 
                      paired.end = FALSE, 
                      swap.strand = TRUE)

Where the object path.to.Bam magically appears, without having been generated elsewhere. But rest assured that this is supposed to be character. Which you apparently already know, as you have

#file                 A path to a BAM file with sequencing reads.

As part of your comment, which you are correct will be tab-completed, so long as it's a character vector that corresponds to an actual file path, or it's an object that exists in your workspace. Here, by definition, a file path is a quoted character string, and it won't be tab-completed if it isn't quoted.

Anyway, that was the problem you had originally, and for which I already provided an answer. Your current problem occurs because you (repeatedly, every time you render this Rmarkdown file (why?)) install transcriptR, but you never load the package which is a fundamental requirement for having the code in the package available.

ADD REPLY
0
Entering edit mode

Thank you so much James.

I am able to put the file path in now, but even after loading the packages it still cannot find the constructTDS function:

> if (!requireNamespace("BiocManager", quietly=TRUE))
+ 
+ if (!requireNamespace("BiocManager", quietly=TRUE))
+ install.packages("BiocManager")
> BiocManager::install("transcriptR")
Bioconductor version 3.9 (BiocManager 1.30.9), R Under development (unstable) (2019-02-24 r76155)
Installing package(s) 'transcriptR'
trying URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/transcriptR_1.12.0.tar.gz'
Content type 'application/x-gzip' length 3469729 bytes (3.3 MB)
==================================================
downloaded 3.3 MB

Bioconductor version 3.9 (BiocManager 1.30.9), ?BiocManager::install for help
* installing *source* package ‘transcriptR’ ...
** R
** data
** inst
** byte-compile and prepare package for lazy loading
Bioconductor version 3.9 (BiocManager 1.30.9), ?BiocManager::install for help
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Bioconductor version 3.9 (BiocManager 1.30.9), ?BiocManager::install for help
* DONE (transcriptR)

The downloaded source packages are in
    ‘/tmp/RtmpMUoytQ/downloaded_packages’
installation path not writeable, unable to update packages: KernSmooth, mgcv
Update old packages: 'littler'
Update all/some/none? [a/s/n]: 
n
> library(GenomicFeatures)
> library(TxDb.Hsapiens.UCSC.hg19.knownGene)
> tds <- constructTDS(file = "~/data/Continuum_ChIPSeq/Continuum_DiffBind/RNASeq_i7Aligned.out.bam", 
+                     region = region, 
+                     fragment.size = 250,
+                     unique = FALSE, 
+                     paired.end = FALSE, 
+                     swap.strand = TRUE)
Error in constructTDS(file = "~/data/Continuum_ChIPSeq/Continuum_DiffBind/RNASeq_i7Aligned.out.bam",  : 
  could not find function "constructTDS"

Even after updating all packages it still can't find the constructTDS function.

ADD REPLY
0
Entering edit mode

You need to do a better job of paying attention, if you ever hope to get anywhere with R or Bioconductor. If I were to make a general observation, I would say that on the whole most R and Bioconductor help pages are complete, but very terse. In effect this means that every single word you read has to actually be, you know, read, and in addition thought about.

So, what I told you yesterday (in bold, to make it stand out and stuff) was

Your current problem occurs because you (repeatedly, every time you render this Rmarkdown file (why?)) install transcriptR, but you never load the package which is a fundamental requirement for having the code in the package available.

And now you show more code where you again, as part of some code that you will presumably repeatedly run, show that you install the transcriptR package but never actually load it, and are then mystified that a function in the package isn't available!

A.) You only have to install a package once, so there is no profit in putting installation code in an Rmd file

B.) To repeat, installing the package is not the same as loading the package. The first makes the package available to R, and the second makes the code available to you.

ADD REPLY
0
Entering edit mode

Hi James,

I apologise for this, I failed to load the transcriptR library like you said. This was not helped by the fact that this library is not loaded in the vignette, also I did not have permission to install the package in the docker I am operating in! But I will stop making excuses. Thank you for your patience and sorry for the frustration I have clearly caused!

Cheers,

Jason

ADD REPLY

Login before adding your answer.

Traffic: 664 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6