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

computeSumFactors(data_mat, clusters=input_groups, min.mean=0.1) gives error #40

Closed
ariberar opened this issue May 15, 2020 · 16 comments
Closed

Comments

@ariberar
Copy link

ariberar commented May 15, 2020

I can run everything without problem until these lines:

%%R -i data_mat -i input_groups -o size_factors
size_factors = computeSumFactors(data_mat, clusters=input_groups, min.mean=0.1)

where I get this error:

Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘assay’ for signature ‘"matrix", "character"’

Any idea whats going on here?

Im using the original code except for these lines that I commented:
#adata.var['gene_id'] = adata.var['gene_id-1']
#adata.var.drop(columns = ['gene_id-1', 'gene_id-0'], inplace=True)

@LuckyMD
Copy link
Contributor

LuckyMD commented May 15, 2020

Hi,

So it seems that within the object you have moved to R cannot be used with the assay() method. Do the versions of scran, SingleCellExperiment and R match with the tutorial?

@ariberar
Copy link
Author

ariberar commented May 15, 2020

Hi, thanks for the answer :D!

These are my versions but I cant find wich versions of scran and SingleCellExperiment that are required for the tutorial:

R -> 4.0.0
scran -> 1.16.0
SingleCellExperiment -> 1.10.1

@LuckyMD
Copy link
Contributor

LuckyMD commented May 16, 2020

So this has not been tested for the newest version of R at all. You can find the versions for the tutorial in the README that is in the same folder as the notebook.

@ariberar
Copy link
Author

Hi again, thanks for the answers! Im a new linux and R user so Im trying to replicate your tutorial like it says in the README

Could you tell me which version of conda were you using for this tutorial? I used sc_tutorial_environment.yml to create my environment and I get R 4.0.0 (maybe if I install a previous version of conda I could get R 3.5) [conda version : 4.8.3; conda-build version : 3.18.11]

Im trying to downgrade R with this command while in the environment created for this tutorial:
conda install r==3.5
and after 1 or few hours of "examining conflicts with..." I get a lot of messages for packages that are in conflict with R>=3.5

I also tried to create a new environment with r==3.5 and then install the R packages but Im getting "installation of package ‘nameOfPackage’ had non-zero exit status" when trying to install the packages used in latest_notebook

@LuckyMD
Copy link
Contributor

LuckyMD commented May 26, 2020

Hi @ariberar, I guess we did not control the version of R in the environment.yaml. I think the exit status messages may have to do with other packages that you need to manually install. I have had issues like this quite commonly, where R doesn't control the dependencies well if you install via conda. The combination of conda and R is never pretty.

What should make things easier though, is a docker that @le-ander created. Could you link to your docker hub url here, @le-ander?

@le-ander
Copy link
Member

Here you go!
https://hub.docker.com/r/leanderd/single-cell-analysis

@ariberar
Copy link
Author

ariberar commented May 26, 2020

Thank you so much for this tutorial and the answers!!
I will try to use docker, I did not know of its existence

I have uninstalled anaconda and installed R 3.6.3 from r-project, rstudio, spyder, jupyter notebooks.

scran==1.14.6; SingleCellExperiment==1.8.0

I was able to install all the packages required by the tutorial (the latest versions) without problems and run the first sections of the code.

scanpy==1.5.0 anndata==0.7.3 umap==0.4.3 numpy==1.18.4 scipy==1.4.1 pandas==1.0.3 scikit-learn==0.23.1 statsmodels==0.11.1 python-igraph==0.8.2 louvain==0.7.0 leidenalg==0.8.0

To concatenate the anndata objects I had to add adata.var_names_make_unique() at the end of the first dataset load because there were genes with equal symbols for example:

mm10_Rp1 mm10_Rp1
mm10_ENSMUSG00000025900 mm10_ENSMUSG00000109048

With this new setup I was able to run computeSumFactors() but I got the following error "'ncol(x)' is not equal to 'length(clusters)'" so I changed data_mat = adata.X.T on the cell above because I think this function in R expects the count matrix to be genesXcells instead cellsXgenes like you said in the introduction. Then it worked.

@LuckyMD
Copy link
Contributor

LuckyMD commented May 26, 2020

Hi @ariberar,

I'm glad things are working out for you! data_mat = adata.X.T should already be in the tutorial script already I believe.

@LuckyMD LuckyMD closed this as completed May 26, 2020
@ariberar
Copy link
Author

You are absolutely right. That line of code is on the tutorial script. I must have changed it before when I was trying to find out a fix to the function error in R.
What do you think about adding adata.var_names_make_unique() at the end of the first data set load?

@LuckyMD
Copy link
Contributor

LuckyMD commented May 27, 2020

In the example data in the notebook it's not needed i think... (and wasn't it automatically called anyway?). But yes, if needed it should be called ;).

@Muedi
Copy link

Muedi commented Sep 22, 2020

I just wanted to add, that the problem can be solved with removing the conda environment and reinstalling it with r-base+3.5 added to the yaml file.

@jvivian-atreca
Copy link

jvivian-atreca commented Jan 26, 2021

@le-ander — the container pushed 4 days ago (docker pull leanderd/single-cell-analysis:210114) runs into this issue as well since the version of R in the container is 4.0.3.

@le-ander
Copy link
Member

@le-ander — the container pushed 4 days ago (docker pull leanderd/single-cell-analysis:210114) runs into this issue as well since the version of R in the container is 4.0.3.

yep, this is already fixed in a new version of the notebook. we are currently working on finalising it for publication here.

@oligomyeggo
Copy link

Hello! I'm running into the same computeSumFactors issue as described here after recently updating to R 4.0.3. I am wondering if the fix that @le-ander mentioned in the new version of the notebook is available?

@LuckyMD
Copy link
Contributor

LuckyMD commented Apr 5, 2021

Hey! Please check #60 for a fix. Still working to get the latest version up to date I'm afraid.

@oligomyeggo
Copy link

Ah, perfect! That worked. Thanks so much, and sorry I missed seeing issue #60.

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

6 participants