PoisonAlien / trackplot

Generate IGV style locus tracks from bigWig files in R
133 stars 16 forks source link

Error in track_extract() #30

Closed h20gg702 closed 7 months ago

h20gg702 commented 7 months ago

Hi, Thank you for developing a useful package. During track_extract(), I faced the following error. Do you know how can I solve this? Thank you for your advice.

`source("https://github.com/PoisonAlien/trackplot/blob/master/R/trackplot.R?raw=true")

#Path to bigWig files
bw.files <- list.files('/COAD_bigWigs/T4/', pattern = '.bw', recursive = FALSE)
folder <- "/COAD_bigWigs/T4/"
bigWigs = paste0(folder,bw.files)

setwd("/COAD_bigWigs/T4/")
bigWigs = read_coldata(bws = bigWigs, build = "hg38")
Checking for files..
Input type: bw
Ref genome: hg38
OK!

#Region to plot
oct4_loci = "chr6:31125776-31144789"
t = track_extract(colData = bigWigs, loci = oct4_loci)
Parsing loci..
    Queried region: chr6:31125776-31144789 [19013 bps]
Querying UCSC genome browser for gene model and cytoband..
Extracting gene models from UCSC:
    chromosome: chr6
    build: hg38
    query: mysql --user genome --host genome-mysql.soe.ucsc.edu -NAD hg38 -e 'select chrom, txStart, txEnd, strand, name, name2, exonStarts, exonEnds from refGene WHERE chrom ="chr6"'
Extracting cytobands from UCSC:
    chromosome: chr6
    build: hg38
    query: mysql --user genome --host genome-mysql.soe.ucsc.edu -NAD hg38 -e 'select chrom, chromStart, chromEnd, name, gieStain from cytoBand WHERE chrom ="chr6"'
Generating windows [10 bp window size]
Extracting signals
    Processing COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions ..
bwtool summary - provide some summary stats for each region in a bed file
   or at regular intervals.
usage:
   bwtool summary loci input.bw[:chr:start-end] output.txt
where:
   -"loci" corresponds to either (a) a bed file with regions to summarize or
    (b) a size of interval to summarize genome-wide.
options:
   -with-quantiles  output 10%/25%/75%/90% quantiles as well surrounding the
                    median.  With -total, this essentially provides a boxplot.
   -with-sum-of-squares
                    output sum of squared deviations from the mean along with 
                    the other fields
   -with-sum        output sum, also
   -skip-median     because the median requires a sorting of the data, this can
                    be time-consuming for large regions, or when using -total
   -keep-bed        if the loci bed is given, keep as many bed file
   -total           only output a summary as if all of the regions are pasted
                    together
   -header          put in a header (fields are easy to forget)

    Processing COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L032_B1_T2_P036.insertions ..
bwtool summary - provide some summary stats for each region in a bed file
   or at regular intervals.
usage:
   bwtool summary loci input.bw[:chr:start-end] output.txt
where:
   -"loci" corresponds to either (a) a bed file with regions to summarize or
    (b) a size of interval to summarize genome-wide.
options:
   -with-quantiles  output 10%/25%/75%/90% quantiles as well surrounding the
                    median.  With -total, this essentially provides a boxplot.
   -with-sum-of-squares
                    output sum of squared deviations from the mean along with 
                    the other fields
   -with-sum        output sum, also
   -skip-median     because the median requires a sorting of the data, this can
                    be time-consuming for large regions, or when using -total
   -keep-bed        if the loci bed is given, keep as many bed file
   -total           only output a summary as if all of the regions are pasted
                    together
   -header          put in a header (fields are easy to forget)

Error: File '/var/folders/pv/zvpnvfk901qdw74sqzy8vg7r0000gn/T//Rtmpt67ZkT/COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions.summary' does not exist or is non-readable. getwd()=='/COAD_bigWigs/T4'`
PoisonAlien commented 7 months ago

Hi, Do your bigWig chromosome names contain chr prefix?

h20gg702 commented 7 months ago

Hi, Do your bigWig chromosome names contain chr prefix?

Thank you for your quick response. I just downloaded it, I am not sure. But I saw the following result. head COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions.bw &??? X???0??R??*?@??%}&I3=?uN=??C???CqCE@?[E??E}??Ec?E?? F?F?,Fc/F@?GF?IFK#@ѯ?@?>?B?>?u?FB???chr1??chr2y?ochr3?? chr4?qV ? chr5? chr6?J. chr75m chr8̣chr]?chr10 .??chr11 chr12 ` This means that the name contains chr?

h20gg702 commented 7 months ago

Hi, Do your bigWig chromosome names contain chr prefix?

Yes, the name contains chr.

bigWigToWig "/COAD_bigWigs/T4/COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions.bw" test.wig
head test.wig
#bedGraph section chr1:0-817299
chr1    0   9999    0
chr1    9999    10099   17.7265
chr1    10099   10199   22.7912
chr1    10199   10299   0
chr1    10299   10399   7.59705
chr1    10399   10499   12.6618
chr1    10499   12899   0
chr1    12899   13299   2.53235
chr1    13299   13399   12.6618
PoisonAlien commented 7 months ago

Hi, Is it possible for you to share the file?

h20gg702 commented 7 months ago

COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions.bw https://drive.google.com/file/d/1eZMWLHWyn0_DJ6RdkkI7vPrehc5zV8D0/view?usp=drive_web Hi, Yes, I can. Please find the bigwig file from this link. Thank you

2024年2月7日(水) 0:13 Anand Mayakonda @.***>:

Hi, Is it possible for you to share the file?

— Reply to this email directly, view it on GitHub https://github.com/PoisonAlien/trackplot/issues/30#issuecomment-1931494909, or unsubscribe https://github.com/notifications/unsubscribe-auth/A47IUUIRKL4LNBK2JCQSOBLYSMZRPAVCNFSM6AAAAABC4QEK7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZRGQ4TIOJQHE . You are receiving this because you authored the thread.Message ID: @.***>

PoisonAlien commented 7 months ago

I have requested for access. Let me know once approve it.

h20gg702 commented 7 months ago

I have approved it. Thanks.

2024年2月7日(水) 9:09 Anand Mayakonda @.***>:

I have requested for access. Let me know once approve it.

— Reply to this email directly, view it on GitHub https://github.com/PoisonAlien/trackplot/issues/30#issuecomment-1932505116, or unsubscribe https://github.com/notifications/unsubscribe-auth/A47IUUIG2QUCXMINH2I6P2LYSOYOHAVCNFSM6AAAAABC4QEK7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZSGUYDKMJRGY . You are receiving this because you authored the thread.Message ID: @.***>

PoisonAlien commented 7 months ago

Hi,

Thanks for sharing the file. I tested and it just works fine.

bigWigs = "~/Downloads/COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions.bw"
> bigWigs = read_coldata(bws = bigWigs, build = "hg38")
Checking for files..
Input type: bw
Ref genome: hg38
OK!
> 
> oct4_loci = "chr6:31125776-31144789"
> 
> t = track_extract(colData = bigWigs, loci = oct4_loci)
Parsing loci..
    Queried region: chr6:31125776-31144789 [19013 bps]
Querying UCSC genome browser for gene model and cytoband..
Extracting gene models from UCSC:
    chromosome: chr6
    build: hg38
    query: mysql --user genome --host genome-mysql.soe.ucsc.edu -NAD hg38 -e 'select chrom, txStart, txEnd, strand, name, name2, exonStarts, exonEnds from refGene WHERE chrom ="chr6"'
Extracting cytobands from UCSC:
    chromosome: chr6
    build: hg38
    query: mysql --user genome --host genome-mysql.soe.ucsc.edu -NAD hg38 -e 'select chrom, chromStart, chromEnd, name, gieStain from cytoBand WHERE chrom ="chr6"'
Generating windows [10 bp window size]
Extracting signals
    Processing COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions ..
OK!
> 
> track_plot(summary_list = t)
Collapsing transcripts..

image

I cant think of any particular reason why it shouldn't work. Could you please try to run bwtool manually from command line and check if it works?

bwtool summary -with-sum -keep-bed -header trackr8e318cb11c2.bed \ 
COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions.bw bw.summary

bw.summary should contain summary for each BED region (attached). trackr8e318cb11c2.bed.txt

h20gg702 commented 7 months ago

bw.summary

Hi, It seems like doen't work,

bwtool summary trackra387111d8532.bed "/Volumes/Crucial X6/TCGA_ATAC/COAD_bigWigs/T4/COAD_561632F0_56A1_4FF0_8DD1_219AD30591D4_X015_S04_L031_B1_T1_P037.insertions.bw" bw.summary 
bwtool summary - provide some summary stats for each region in a bed file
   or at regular intervals.
usage:
   bwtool summary loci input.bw[:chr:start-end] output.txt
where:
   -"loci" corresponds to either (a) a bed file with regions to summarize or
    (b) a size of interval to summarize genome-wide.
options:
   -with-quantiles  output 10%/25%/75%/90% quantiles as well surrounding the
                    median.  With -total, this essentially provides a boxplot.
   -with-sum-of-squares
                    output sum of squared deviations from the mean along with 
                    the other fields
   -with-sum        output sum, also
   -skip-median     because the median requires a sorting of the data, this can
                    be time-consuming for large regions, or when using -total
   -keep-bed        if the loci bed is given, keep as many bed file
   -total           only output a summary as if all of the regions are pasted
                    together
   -header          put in a header (fields are easy to forget)
PoisonAlien commented 7 months ago

Hi, You dont need to quote the path to the bigwig file. Could you please unquote them and try again?

h20gg702 commented 7 months ago

Hi, Sorry for my late response. Unquote still doesn't work. But moving the bigwig file from the external SSD to the local folder works! My SSD name is "Crucial X6". This space may cause this problem?

2024年2月7日(水) 23:59 Anand Mayakonda @.***>:

Hi, You dont need to quote the path to the bigwig file. Could you please unquote them and try again?

— Reply to this email directly, view it on GitHub https://github.com/PoisonAlien/trackplot/issues/30#issuecomment-1933538620, or unsubscribe https://github.com/notifications/unsubscribe-auth/A47IUUJSV6PSA5WU3JHLE4TYSSAXJAVCNFSM6AAAAABC4QEK7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZTGUZTQNRSGA . You are receiving this because you authored the thread.Message ID: @.***>

PoisonAlien commented 7 months ago

I can't be sure. Since this is resolved, I will close the issue.