Entering edit mode
iaingallagher
•
0
@iaingallagher-13496
Last seen 7.8 years ago
Hi
In the script below I'm trying to plot a single gene using Gvis. On trying to create the gene track I get the following error:
Error in chromosome[1] : object of type 'closure' is not subsettable
Can anyone shed any light on this?
Code follows:
# plot tfbs in IS core correlating genes library(Gviz) library(GenomicRanges) library(biomaRt) rm(list=ls()) # gene syms syms <- c("MCCC1","PCYT2","ALDH6A1","DHTKD1","ECHDC3","SLC43A1") # create GenomicFeatures for the genes using biomaRt mart <- useMart(biomart="ensembl", dataset="hsapiens_gene_ensembl") gene_data <- getBM(attributes = c('chromosome_name', 'start_position', 'end_position', 'strand', 'ensembl_gene_id', 'ensembl_exon_id', 'ensembl_transcript_id', 'hgnc_symbol'), filters = 'hgnc_symbol', values = syms , mart = mart) # change strand info to required labels ('-', '+') gene_data$strand <- ifelse(gene_data$strand==-1, '-', '+') gene_data$chromosome_name <- as.character(paste('chr', gene_data$chromosome_name, sep='')) # create seqinfo object chrs <- unique(gene_data$chromosome_name) chr_lns <- c(107043718, 133797422, 198295559, 83257441, 135086622) isC <- rep(FALSE, 5) hum_gen <- rep('hg19', 5) seq_info <- Seqinfo(seqnames=chrs, seqlengths=chr_lns, isCircular=isC, genome=hum_gen) # make GRanges obj gene_GR <- makeGRangesFromDataFrame(gene_data, seqinfo=seq_info, seqnames.field = 'chromosome_name', start.field = 'start_position', end.field = 'end_position', strand.field = 'strand', keep.extra.columns=TRUE) # create tracks for first gene # get info gene1 <- gene_GR[gene_GR$hgnc_symbol==syms[1]] gen <- 'hg19' gene_track <- GeneRegionTrack(gene1, genome = gen, chromosome = seqnames, name = "Gene Model")
Error in chromosome[1] : object of type 'closure' is not subsettable
Thanks,
Iain
> sessionInfo() R version 3.4.0 (2017-04-21) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.6 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] grid parallel stats4 stats graphics grDevices utils datasets methods [10] base other attached packages: [1] ensembldb_2.0.3 AnnotationFilter_1.0.0 [3] BiocInstaller_1.26.0 TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 [5] GenomicFeatures_1.28.4 AnnotationDbi_1.38.1 [7] Biobase_2.36.2 biomaRt_2.32.1 [9] BSgenome.Hsapiens.UCSC.hg19_1.4.0 BSgenome_1.44.0 [11] rtracklayer_1.36.4 Biostrings_2.44.1 [13] XVector_0.16.0 Gviz_1.20.0 [15] GenomicRanges_1.28.3 GenomeInfoDb_1.12.2 [17] IRanges_2.10.2 S4Vectors_0.14.3 [19] BiocGenerics_0.22.0 loaded via a namespace (and not attached): [1] httr_1.2.1 bit64_0.9-7 AnnotationHub_2.8.2 [4] splines_3.4.0 shiny_1.0.3 Formula_1.2-2 [7] interactiveDisplayBase_1.14.0 latticeExtra_0.6-28 blob_1.1.0 [10] GenomeInfoDbData_0.99.0 Rsamtools_1.28.0 yaml_2.1.14 [13] RSQLite_2.0 backports_1.1.0 lattice_0.20-35 [16] biovizBase_1.24.0 digest_0.6.12 RColorBrewer_1.1-2 [19] checkmate_1.8.3 colorspace_1.3-2 httpuv_1.3.5 [22] htmltools_0.3.6 Matrix_1.2-10 plyr_1.8.4 [25] pkgconfig_2.0.1 XML_3.98-1.9 zlibbioc_1.22.0 [28] xtable_1.8-2 scales_0.4.1 BiocParallel_1.10.1 [31] htmlTable_1.9 tibble_1.3.3 ggplot2_2.2.1 [34] SummarizedExperiment_1.6.3 nnet_7.3-12 lazyeval_0.2.0 [37] mime_0.5 survival_2.41-3 magrittr_1.5 [40] memoise_1.1.0 foreign_0.8-69 tools_3.4.0 [43] data.table_1.10.4 matrixStats_0.52.2 stringr_1.2.0 [46] munsell_0.4.3 cluster_2.0.6 DelayedArray_0.2.7 [49] compiler_3.4.0 rlang_0.1.1 RCurl_1.95-4.8 [52] dichromat_2.0-0 VariantAnnotation_1.22.3 htmlwidgets_0.9 [55] bitops_1.0-6 base64enc_0.1-3 gtable_0.2.0 [58] curl_2.7 DBI_0.7 R6_2.2.2 [61] GenomicAlignments_1.12.1 gridExtra_2.2.1 knitr_1.16 [64] bit_1.1-12 Hmisc_4.0-3 ProtGenerics_1.8.0 [67] stringi_1.1.5 Rcpp_0.12.11 rpart_4.1-11 [70] acepack_1.4.1
Fixed this. The problem was the use of
in the last line... seqnames being a function. Hey ho.
best,
i