LoadError: MethodError: Cannot `convert` an object of type Array{Float64,2} to an object of type EasyFITS.FitsImage{Float64,2}

LoadError: MethodError: Cannot convert an object of type Array{Float64,2} to an object of type EasyFITS.FitsImage{Float64,2}
Closest candidates are:
convert(::Type{#s15} where #s15<:AbstractArray, ::EasyFITS.FitsImage) at C:\Users\assia.julia\packages\EasyFITS\ybRPO\src\EasyFITS.jl:479
convert(::Type{T}, ::T) where T<:AbstractArray at abstractarray.jl:14
convert(::Type{T}, ::LinearAlgebra.Factorization) where T<:AbstractArray at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\LinearAlgebra\src\factorization.jl:53

please some help.

Hello @assia855, welcome to the Julia community!

Regarding your question, it would be possible to help you if you provide more information. What exactly you did in your program before you get this result? What packages you were using? The best way to help us help you is to provide MWE, i.e. Minimal Working Example. Just a few lines, that someone can also run in their REPL and get the same error message. Also, please remember that MWE should not include data that is only in your possession.

You can read more about MWE and some other simple things that can ease your life and get answer quickly here: Please read: make it easier to help you

2 Likes

using FASTX
using BioSequences
using CodecZlib

function demux(sample_table, fastq_file, mismatch)
barcode_sample_dict = Dict{String,String}()
f = open(sample_table, “r”)
for line in readlines(f)
array = split(line, “,”)
barcode_sample_dict[array[4]] = array[2]
end
close(f)
keys_as_vector = collect(keys(barcode_sample_dict))

barcodes = LongDNASeq.(keys(barcode_sample_dict))
dplxr = Demultiplexer(barcodes, n_max_errors=parse.(Int8, mismatch), distance=:hamming)

output_dict = Dict{String, String}()
reader = FASTQ.Reader(GzipDecompressorStream(open(fastq_file)))
for record in reader
    index = last(split(FASTQ.description(record),":"))
    check = demultiplex(dplxr, LongDNASeq(index))
    if check[1] !== 0
        barcode = keys_as_vector[check[1]]
        sample = barcode_sample_dict[barcode]
        output_dict[sample] = record
    else
    end
end
close(reader)

for sample in keys(output_dict)
    println("$sample")
end

end

@time demux(ARGS[1], ARGS[2], ARGS[3])

julia demux_func.jl SampleSheet.NEXTflex1.csv 17-4-F-BR_S1_L001_R1_001_head4000.fastq.gz 0

ERROR: LoadError: MethodError: Cannot convert an object of type FASTX.FASTQ.Record to an object of type String

Closest candidates are:

convert(::Type{String}, ::BioSequence, ::BioSequences.AsciiAlphabet) at /Users/xzhong/.julia/packages/BioSequences/k4j4J/src/biosequence/conversion.jl:20

convert(::Type{T}, ::T) where T<:AbstractString at strings/basic.jl:229

convert(::Type{T}, ::AbstractString) where T<:AbstractString at strings/basic.jl:230

Stacktrace:

[1] setindex!( ::Dict{String,String}, ::FASTX.FASTQ.Record, ::String ) at ./dict.jl:380

[2] demux( ::String, ::String, ::String ) at /Users/xzhong/scripts/julia/demux_func.jl:46

[3] top-level scope at ./timing.jl:174

[4] include( ::Function, ::Module, ::String ) at ./Base.jl:380

[5] include( ::Module, ::String ) at ./Base.jl:368

[6] exec_options( ::Base.JLOptions ) at ./client.jl:296

[7] _start() at ./client.jl:506

in expression starting at /Users/xzhong/scripts/julia/demux_func.jl:61

I can print out the ‘record’ as what I want, but cannot build a key-value pair.
I’m new to Julia. Any suggestions are welcome! Thank you!

I resolved this error on my code by adding “get(Array,…)”:

reader = get(Array,FASTQ.Reader(GzipDecompressorStream(open(fastq_file))))