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

how to create a Delorean object #5

Open
kasumaz opened this issue Mar 24, 2019 · 15 comments
Open

how to create a Delorean object #5

kasumaz opened this issue Mar 24, 2019 · 15 comments

Comments

@kasumaz
Copy link

kasumaz commented Mar 24, 2019

No description provided.

@kasumaz
Copy link
Author

kasumaz commented Mar 24, 2019

Dear Developers,
This looks like a very nice tool to use. I am working with the adult version of the cells as used in the tutorial it seems.
I am trying to figure out how I can create a delorean object and been looking around for this.
I have my data with cells (stemcell_1, stemcell_2, stemcell_3, progenitor_1, progenitor_2, progenitor_3, etc) in columns and genes as the first row. I would like to tell it which cell clusters are what.
In the end, I would like to visualise some of the same genes in the tutorial like Sox2, Bmp4.

Would you happen to have a piece of script that I can use to set up a delorean object and then I can try running the rest. I will be sure to cite this nice package.
Many thanks, Kaz

@JohnReid
Copy link
Owner

Thanks for your interest ;)
If you look at the vignette, it shows an example: https://cran.r-project.org/web/packages/DeLorean/vignettes/DeLorean.html

Basically you need 3 objects to run DeLorean, a matrix of the expression values, a data frame for the gene meta data (can be minimal) and a data frame for the cell meta data. Look at data(GuoDeLorean) for examples of these objects and the vignette for the code to use them.

I hope that helps.

@kasumaz
Copy link
Author

kasumaz commented Mar 26, 2019

Dear John,
Many thanks for the fast reply.

I could try yesterday and now again.
I have the following error message:

Error in de.lorean(sce.expr, sce.gene.meta, sce.cell.meta) :
is.matrix(expr) is not TRUE

I looked at my own expr matrix (shorter subset of 132 cells in columns and 17745 genes in rows) and other files for quo, kouno and windram datasets. At least my eyes cant see what could be wrong.

Would it be worth sending over the 3 files? In case you ever had time to check it out whenever you back to DeLorean again. Once I get it running I normally okay with it.
Thanks so much for you help.

@JohnReid
Copy link
Owner

If you send over a small working example of what goes wrong I can definitely help.

@kasumaz
Copy link
Author

kasumaz commented Mar 26, 2019

data-Kaz.zip

Hi, I send over the 3 files. I started with a small subset to get it up and running and then try with the full sample. The tutorials work for me here. I guess all is installed correctly. It might just be the small "devil is in the detail" that brings up the error.
Thank you so very much for looking.

@JohnReid
Copy link
Owner

I need the actual R objects not the CSV files. The problem is that your expr object is not a matrix. Try class(expr) and let me know what R prints. You can save the R objects using saveRDS()

@kasumaz
Copy link
Author

kasumaz commented Mar 26, 2019

If I check:

class(sce.expr)
[1] "data.frame"

I attach the matrix here too as a zip. Thanks a lot.
matrix.zip

@JohnReid
Copy link
Owner

A data.frame is not a matrix. You need to convert sce.expr to a matrix. as.matrix(sce.expr) should do the job.

@kasumaz
Copy link
Author

kasumaz commented Mar 26, 2019

I used the following:
expr<-as.matrix(sce.expr) ##to turn my data into a matrix. This worked.

I tried also other ways:
data.matrix(sce.expr, rownames.force = NA) ##doesnt work
expr<-as.matrix(sce.expr) ##another error pops up
expr <- as.data.frame(t(sce.expr))## doesnt work
data.matrix(sce.expr) ##doesnt work

I checked the class of each of these and they were still as a data frame.

In the first one at the top that worked...when I run it, i get:
I have gone back to change the cell meta data names to correspond. I tried either way but I get the error:

Error in de.lorean(expr, sce.gene.meta, sce.cell.meta) :
ncol(expr) == nrow(cell.meta) is not TRUE

@JohnReid
Copy link
Owner

That is progress. The error says that the expr matrix should have the same number of columns as the cell.meta data frame has rows. Does it?

@kasumaz
Copy link
Author

kasumaz commented Mar 26, 2019

The matrix that is made, in the very first column (inserted before genes) there are added incremental numbers that fill all the way down to the end of the gene column. I believe the first new column added should not be there. This makes the new matrix one column larger than the info in the cell meta data. I have been trying something simple where the first column in the matrix can be ignored or deleted. I cant seem to chop it off. My R skills might have reached the maximum. But looking around for functions that delete the first column on the new matrix.
Would it be easier if I could send you the 3 files again so that you can adapt a script that gets me going that works with you? In this way I would know how to process in future and be up and running.

@JohnReid
Copy link
Owner

You can drop the first column of a matrix a by doing a[, -1]

@kasumaz
Copy link
Author

kasumaz commented Mar 26, 2019

this works. when I was saving it and checking it as a .csv the original with extra was showing up.

I still get the error:
Error in de.lorean(expr, sce.gene.meta, sce.cell.meta) :
ncol(expr) == nrow(cell.meta) is not TRUE
when I look at the cell meta file, the column names and amount on the matrix are the same as the original input matrix. I have tried bits and pieces to make it work.
Maybe I should stop here and think of a similar package as DeLorean to use. You have helped tremendously.

@JohnReid
Copy link
Owner

I would either ask someone who knows R to help a little bit or use the GrandPrix package. dim(expr) and dim(cell.meta) will tell you the number of rows and columns in each. Obviously there are other packages as well.

@kasumaz
Copy link
Author

kasumaz commented Mar 26, 2019

I will do that. There is someone here using monocle so perhaps thats an alternative once they have some time.
Thanks again. Kaz

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

No branches or pull requests

2 participants