Question: Adding data to R S4 object
0
gravatar for Za
2.1 years ago by
Za130
Za130 wrote:

Hi,

in this tutorial in spite of most of tutorials like making object in scater there is no something to help me how I adapt my own expression data in sc object

https://github.com/xu-lab/SINCERA/blob/master/demo/mouselung.e16.5.R

library(SINCERA)

# Loading E16.5 data
data("E16.5")


# expression matrix
dim(expressions)

# cell information
head(cells)

# gene information
head(genes)

# The analysis starts with running the construct function to create an R S4 object,
# which will hold all the data and analysis results.
sc <- construct(exprmatrix=expressions,
                samplevector=paste("sample", cells$SAMPLE, sep=""))

I tried to replace my own data but returns error

> sc <- construct(exprmatrix=ipf.exprmatrix)
Error in construct(exprmatrix = ipf.exprmatrix) : 
  object 'rexpr' not found
> 
>

and sc object already contains expression data and metadata

Any help please

sc cell rna-seq R • 733 views
ADD COMMENTlink modified 2.1 years ago • written 2.1 years ago by Za130
2

Hello Za/F !

It appears that your post has been cross-posted to another site: https://bioinformatics.stackexchange.com/questions/4905/creating-an-r-s4-object

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by genomax89k
1

in the code you've posted, you aren't replacing the values that are currently stored in sc; you are constructing a brand-new object and storing that in sc. It may be possible to hack it so that you can update the rexpr entry of the pre-existing sc using sc@rexpr <- ipf.exprmatrix. (I'd strongly urge you to construct a new object, or use whatever setter generics are provided by the author, rather than hacking the slots using @, though)

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by russhh5.5k

Sorry, but I am very bad in R and authors did not provide any information :(

ADD REPLYlink written 2.1 years ago by Za130
2

Looking at the source code for sincera it looks like you've found a bug (see line 99 of https://github.com/xu-lab/SINCERA/blob/master/R/sincera.R ). Post as issue via github and make a pull request: you just need to change rexpr to rexprs. Sincera is throwing the error because it can't find rexpr, a variable that isn't defined in the construct function; it should really be looking for rexprs

ADD REPLYlink written 2.1 years ago by russhh5.5k

Actually I can not figure out how to replace my own matrix

> sc <- construct(exprmatrix=my_matrix)
Error in construct(exprmatrix = my_matrix) : object 'rexpr' not found
> sc@rexprs=my_matrix
> sc <- construct(exprmatrix=rexprs)
Error in construct(exprmatrix = rexprs) : object 'rexprs' not found
>

sc@ rexprs exists but I don't know how to make Sincera object

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by Za130
1

But then, you are doing exactly the same thing you've just been doing. The error is inside the source code for the construct function. You can get around it if you pass in a samplevector in addition to your exprmatrix. Try downloading the github repo for sincera, modify the line of code i told you about, install the package from your modified source code, and then see if the problem remains.

.....

then when that works, clone the repo, fix the code, submit a PR and the package will be fixed for whoever uses it next. If you need someone to explain how to submit pull-requests etc, I'm happy to help

ADD REPLYlink written 2.1 years ago by russhh5.5k

Thank you

By changing rsampleinfo <- rep("sample1", dim(rexpr)[2]) to rsampleinfo <- rep("sample1", dim(rexprs)[2]) in source and running the source likely I construct my sincera object with my matrix

I am going to try the rest but I got confused about

> # gene information
> head(genes)
                          SYMBOL TF          TF_SOURCE use_as_marker_1 use_as_marker_2 use_as_marker_3 use_as_marker_5 use_as_marker_7 use_as_marker_8 use_as_marker_9
ENSMUSG00000044719 E230025N22Rik  0 genomatix_20140512               0               0               0               0               0               0               0
ENSMUSG00000044591    AC112933.1  0 genomatix_20140512               0               0               0               0               0               0               0
ENSMUSG00000044712       Slc38a6  0 genomatix_20140512               0               0               0               0               0               0               0
ENSMUSG00000044734     Serpinb1a  0 genomatix_20140512               0               0               0               0               0               0               0
ENSMUSG00000044726      BC030476  0 genomatix_20140512               0               0               0               0               0               0               0
ENSMUSG00000044724        Gpr152  0 genomatix_20140512               0               0               0               0               0               0               0
>

This data frame has been provided beforehand, does that mean I should have such a data frame before clustering and differential expression or this data frame would be produced after clustering and DE steps?

ADD REPLYlink written 2.1 years ago by Za130
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1650 users visited in the last hour