Regarding somatic signature package
2
0
Entering edit mode
sj1 ▴ 10
@sj1-9565
Last seen 8.4 years ago

Hi,

I have gone through your paper, Inferring Somatic Signatures from Single Nucleotide Variant Calls and I want to run somatic signature package on the exome samples.Sir, I want to know the structure of the input file,the problem that I am facing is not able to export the datasets of the SomaticCancerAlterations package while I have successfully exported the datasets of SomaticSignatures package.I have already run this package for the demo data supplied with this package.

The error that I am getting while exporting the datasets of the SomaticCancerAlterations package is

Error in as.vector(x) : no method for coercing this S4 class to a vector

Looking for your response.

Swati

somatic signature • 2.6k views
ADD COMMENT
0
Entering edit mode

Hi Swati, there is little information that can help us understand the problem. Can you please provide a minimal example that produces your error, along with the information mentioned in the posting guide? This would be very helpful.

ADD REPLY
1
Entering edit mode

To export one of the dataset of the SomaticSignatures package dataset in R I have used this command

data(sca_mm)

write.table(sca_mm, "/location to store data/sca_mm.txt", sep="\t"), this is working fine but while exporting one of the dataset of SomaticCancerAlterations package using

data(gbm_tcga)

write.table(gbm_tcga, "/location to store data/gbm_tcga.txt", sep="\t") , getting error as.vector(x) : no method for coercing this S4 class to a vector

 

ADD REPLY
0
Entering edit mode

Hi Sir,

The previous problem is solved,thanks for your effort.I have a question the plot that is generated for Mutation spectrum after giving this function -

plotMutationSpectrum(sca_motifs, "study") is Contribution vs Motif plot.What is contribution means here??

Another question regarding Mutation signature plot is that while generating the plot multiple times(generated 5 times) we are getting different results(results are not similar in all 5 plots) using this function -

plotSignatures(sigs_nmf) + ggtitle("Somatic Signatures: NMF - Barchart")

Need your help.Looking for your response.

Thanks

Swati.

 

ADD REPLY
2
Entering edit mode
@sean-davis-490
Last seen 3 months ago
United States

Your comment was quite helpful.  The write.table() function works only with "table-like" data structures like data.frames and matrices.  However, gbm_tcga is a GRanges object.  To use write.table(), gbm_tcga must first be converted to a data.frame.  Fortunately, this is easy to do:

gbm_df = as.data.frame(gbm_tcga)
write.table(gbm_df, ....)

 

ADD COMMENT
2
Entering edit mode
Julian Gehring ★ 1.3k
@julian-gehring-5818
Last seen 5.6 years ago

The write.table function of R can deal with only a few data types, such as matrices or data frames. In your example, sca_mm is a matrix (see class(sca_mm)), so everything works out of the box. In the second part, gbm_tcga is a very different type of data (see class(gbm_tcga)), represented as a GRanges object. And write.table does not know how to deal with that. Converting it to e.g. a data.frame works then:

df = as(gbm_tcga, "data.frame")
write.table(df, ...)
ADD COMMENT
0
Entering edit mode

Thanks for your response,it is really helpful.One more query is my input file is a .txt format then how to create a GRange object of a .txt file. 

ADD REPLY
1
Entering edit mode

See the help for makeGRangesFromDataFrame().

ADD REPLY
0
Entering edit mode

I have successfully exported gbm_tcga dataset in a dataframe format.Now I want to create a GRange object but I am getting an error

Error in .find_start_end_cols(df_colnames0, start.field0, end.field0) :
  cannnot determine start/end columns

executed command is -

makeGRangesFromDataFrame("location of the file",
                         keep.extra.columns=FALSE,
                         ignore.strand=FALSE,
                         seqinfo=NULL,
                         seqnames.field=c("seqnames",
                                            "width",
                                          "strand","Hugo_Symbol",
                                          "Entrez_Gene_Id",
                                          "Variant_Classification",
                                          "Variant_Type",
                                          "Reference_Allele",
                                          "Tumor_Seq_Allele1",
                                          "Tumor_Seq_Allele2",
                                          "Verification_Status",
                                          "Validation_Status",
                                          "Mutation_Status",
                                          "Patient_ID","Sample_ID",
                                          "index"),
                         start.field="start",
                         end.field=c("end"),
                         starts.in.df.are.0based=FALSE)

ADD REPLY
0
Entering edit mode

The seqnames.field, start.field, and end.field should have the column names of the chromosome, start position, and end positions from the data.frame.  

ADD REPLY
0
Entering edit mode

Hi,

I have executed this and getting an error

Error in .normarg_field(seqnames.field, "seqnames") :
  object 'chromosome' not found

Executed this command -

> makeGRangesFromDataFrame("file location",
+     keep.extra.columns=FALSE,
+     ignore.strand=FALSE,
+     seqinfo=NULL,
+     seqnames.field=c(chromosome),
+     start.field=c(start),
+     end.field=c(end),
+     starts.in.df.are.0based=FALSE)
 

My file looks like this

seqnames    chromosome    start    end    width    strand    Hugo_Symbol    Entrez_Gene_Id    Variant_Classification    Variant_Type    Reference_Allele    Tumor_Seq_Allele1    Tumor_Seq_Allele2    Verification_Status    Validation_Status    Mutation_Status    Patient_ID    Sample_ID    index
1    1    887446    887446    1    *    NOC2L    26155    Missense_Mutation    SNP    G    G    A    NA    Untested    Somatic    TCGA-06-5858    TCGA-06-5858-01A-01D-1696-08    7211
2    1    909247    909247    1    *    PLEKHN1    84069    Missense_Mutation    SNP    C    C    T    NA    Untested    Somatic    TCGA-32-1977    TCGA-32-1977-01A-01D-1353-08    16958

ADD REPLY
0
Entering edit mode

The field names should be character strings, and as such need to be in quotes: e.g. seqnames.field="chromosom"

ADD REPLY
0
Entering edit mode

Executed in 2 ways-

1st one-

> makeGRangesFromDataFrame("file location",
+     keep.extra.columns=FALSE,
+     ignore.strand=FALSE,
+     seqinfo=NULL,
+     seqnames.field=c("chromosome"),
+     start.field=c("start"),
+     end.field=c("end"),
+     starts.in.df.are.0based=FALSE)
Error in .find_start_end_cols(df_colnames0, start.field0, end.field0) :
  cannnot determine start/end columns

2nd one-

> makeGRangesFromDataFrame("file location",
+     keep.extra.columns=FALSE,
+     ignore.strand=FALSE,
+     seqinfo=NULL,
+     seqnames.field=c("chromosome"),
+     start.field=start,
+     end.field=end,
+     starts.in.df.are.0based=FALSE)
Error in .normarg_field(start.field, "start") :
  'start.field' must be a character vector with no NAs

ADD REPLY
0
Entering edit mode

I doubt that the first argument for makeGRangesFromDataFrame can be the name of a file, but must be a data frame. You can have a look at the help of that function for some practical examples and details.

ADD REPLY
0
Entering edit mode

Input file i.e, the first argument is in tab separated matrix format.

ADD REPLY
0
Entering edit mode

The first input argument `df` has to be a data frame itself, not a path to a file. From the manual page of the function:

df: A data.frame or DataFrame object. If not, then the function
          tries to turn ‘df’ into a data frame with
          ‘as.data.frame(df)’

 

ADD REPLY
0
Entering edit mode

Hi guys,

In GenomicRanges 1.22.4, makeGRangesFromDataFrame() now fails with a more informative error message when given the path to a file.

Cheers,

H.

 

ADD REPLY

Login before adding your answer.

Traffic: 611 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6