Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with creating CopyKit object with external data #101

Open
rmapbut opened this issue Oct 16, 2024 · 5 comments
Open

Issue with creating CopyKit object with external data #101

rmapbut opened this issue Oct 16, 2024 · 5 comments
Labels
question Further information is requested

Comments

@rmapbut
Copy link

rmapbut commented Oct 16, 2024

Hi, I would be very grateful for your help with this:

I am trying to create a CopyKit object using a segment mean ratios matrix and a genomic ranges scaffold (a Granges object made using GenomicRanges). The length of the matrix and GenomicRanges objects are the same.

Below is an example of part of the matrix:

Cell1 Cell2 Cell3 Cell4 Cell5 Cell6 Cell7 Cell8 Cell9 Cell10 Cell11 Cell12
[1,] 2 2 2 2 2 2 2 2 2 2 2 2
[2,] 2 2 2 2 2 2 2 2 2 2 2 2
[3,] 2 2 2 2 2 2 2 2 2 2 2 2

And the code I am using:

obj <- CopyKit(list(segment_ratios = count_matrix), rowRanges = genomic_ranges_scaffold)

And the error I am getting:

Error in validObject(.Object) :
invalid class “CopyKit” object: invalid object for slot "consensus" in class "CopyKit": got class "list", should be or extend class "data.frame"

I was wondering if you knew how best to address the error?

Thank you!

@rmapbut rmapbut closed this as completed Oct 16, 2024
@rmapbut rmapbut reopened this Oct 16, 2024
@darlanminussi
Copy link
Collaborator

Hi, could you please provide a reproducible example?

@darlanminussi darlanminussi added the question Further information is requested label Oct 24, 2024
@darlanminussi
Copy link
Collaborator

Hi, Pinging again for a reproducible example, if not possible, please close the issue.

@AndreeaOber
Copy link

Hello,

I'm having the same issue as @rmapbut.

As I'm working with mouse data, I'm trying to follow the instructions for using external count data and scaffolds (https://navinlabcode.github.io/CopyKit-UserGuide/pre-processing.html#from-external-count-data-or-user-defined-scaffolds). When I input a counts matrix and genomic ranges object into CopyKit(), I get the following error:

Error in validObject(.Object) :
invalid class “CopyKit” object: invalid object for slot "consensus" in class "CopyKit": got class "list", should be or extend class "data.frame"

Reproducible example:

library(GenomicRanges)
library(copykit)

#counts matrix
cell_names <- c("TCAATTCTCCTCAAGA", "TTCTGTAAGTATAGTG", "TTGTTCAAGACCGCAA", "TTGTTCACATGCTATG", "TTGTTCATCAAATGGA")
bin_names <- c("1_100000001_100100000", "1_100100001_100200000", "1_100200001_100300000", "1_100300001_100400000", "1_100400001_100500000")
c_mat <- matrix(c(18, 14, 20, 16, 11,
                  20, 15, 10, 23, 12,
                  29, 17, 21, 15, 12,
                  23, 18, 30, 23, 26,
                  21, 20 ,35, 31, 18),
                nrow=5, byrow=TRUE, dimnames=list(bin_names, cell_names))

#ranges
gr <- data.frame(seqnames=rep("1", 5),
                 start=c(100000001, 100100001, 100200001, 100300001, 100400001),
                 end=c(100100000, 100200000, 100300000, 100400000, 100500000),
                 GCcontent=c(0.382, 0.384, 0.386, 0.380, 0.377),
                 mappability=c(0.927, 0.905, 0.847, 0.850, 0.879))
gr <- makeGRangesFromDataFrame(gr, keep.extra.columns = TRUE)

#make CopyKit object
ck <- CopyKit(list(bincounts = c_mat), rowRanges = gr)

Thank you!

@AndreeaOber
Copy link

Hi again,

I managed to solve my issue. For anyone else with this problem, it seems the first argument should be passed specifically to the assays parameter.

ck <- CopyKit(assays = list(bincounts = c_mat), rowRanges = gr)

It's buried in the code for function runCountReads, but it would be great if this were in the documentation too. Thanks.

@darlanminussi
Copy link
Collaborator

@AndreeaOber Thank you so so much for finding the solution and putting it here for other users. We will try to put that in the documentation. I suspect some of the plotting functions might breakdown with alternative genomes. Was that the case? If so let's us know.

Thank you again though. Going into the code and finding the error is way beyond what we could ask for as developers and helps us immensely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants