Changing this function to work

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












-2












$begingroup$


I have this matrix of expression data



> head(data[,1:6])
Symbol cl1 cl1.1 cl1.2 cl1.3 cl1.4
1 ACTB 14.07922 14.25211 13.547206 14.046814 15.33551
2 ATP5F1 10.43386 10.34219 9.671036 9.862641 10.39786
3 DDX5 13.99250 13.29734 13.706894 13.084000 13.73379
4 EEF1G 14.35303 14.26112 13.523434 13.327333 13.97747
5 GAPDH 16.07695 15.61435 15.454911 15.233670 15.90100
6 NCL 14.35149 13.32919 13.051861 12.704973 13.55680
>


I have 24 samples as cl1 and 30 samples as cl2



I want to do a t.tset, I have this function but I am not sure Why I am getting error by



volcan <- function(data, cl1, cl2) 
tt <- t(apply(data[, -1], 1, function(d)z <- t.test(d[cl1], d[cl2]); c(z$estimate, z$p.value)))
tt[, 1] <- tt[, 1] - tt[, 2]
tt <- tt[, -2]
tt <- cbind(symbol=data[, 1], as.data.frame(tt), rank=NA)
tt[, 3] <- -log(tt[, 3], 10)
colnames(tt)[2:3] <- c("log.ratio", "neg.log(t.test)")
tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)
tt <- tt[order(tt[, 4], decreasing=T), ]
tt

Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"


When I am running function as whole says that



Error: unexpected '}' in "}"


When I am putting




tt= volcan(data,cl1,cl2)




and doing line by line going down after



tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)


Says



Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"


I am not sure why, I put comma in



 tt[, 4] <- sqrt(tt[, 2]^4 , tt[, 3]^2)


But another error










share|improve this question











$endgroup$
















    -2












    $begingroup$


    I have this matrix of expression data



    > head(data[,1:6])
    Symbol cl1 cl1.1 cl1.2 cl1.3 cl1.4
    1 ACTB 14.07922 14.25211 13.547206 14.046814 15.33551
    2 ATP5F1 10.43386 10.34219 9.671036 9.862641 10.39786
    3 DDX5 13.99250 13.29734 13.706894 13.084000 13.73379
    4 EEF1G 14.35303 14.26112 13.523434 13.327333 13.97747
    5 GAPDH 16.07695 15.61435 15.454911 15.233670 15.90100
    6 NCL 14.35149 13.32919 13.051861 12.704973 13.55680
    >


    I have 24 samples as cl1 and 30 samples as cl2



    I want to do a t.tset, I have this function but I am not sure Why I am getting error by



    volcan <- function(data, cl1, cl2) 
    tt <- t(apply(data[, -1], 1, function(d)z <- t.test(d[cl1], d[cl2]); c(z$estimate, z$p.value)))
    tt[, 1] <- tt[, 1] - tt[, 2]
    tt <- tt[, -2]
    tt <- cbind(symbol=data[, 1], as.data.frame(tt), rank=NA)
    tt[, 3] <- -log(tt[, 3], 10)
    colnames(tt)[2:3] <- c("log.ratio", "neg.log(t.test)")
    tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)
    tt <- tt[order(tt[, 4], decreasing=T), ]
    tt

    Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"


    When I am running function as whole says that



    Error: unexpected '}' in "}"


    When I am putting




    tt= volcan(data,cl1,cl2)




    and doing line by line going down after



    tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)


    Says



    Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"


    I am not sure why, I put comma in



     tt[, 4] <- sqrt(tt[, 2]^4 , tt[, 3]^2)


    But another error










    share|improve this question











    $endgroup$














      -2












      -2








      -2





      $begingroup$


      I have this matrix of expression data



      > head(data[,1:6])
      Symbol cl1 cl1.1 cl1.2 cl1.3 cl1.4
      1 ACTB 14.07922 14.25211 13.547206 14.046814 15.33551
      2 ATP5F1 10.43386 10.34219 9.671036 9.862641 10.39786
      3 DDX5 13.99250 13.29734 13.706894 13.084000 13.73379
      4 EEF1G 14.35303 14.26112 13.523434 13.327333 13.97747
      5 GAPDH 16.07695 15.61435 15.454911 15.233670 15.90100
      6 NCL 14.35149 13.32919 13.051861 12.704973 13.55680
      >


      I have 24 samples as cl1 and 30 samples as cl2



      I want to do a t.tset, I have this function but I am not sure Why I am getting error by



      volcan <- function(data, cl1, cl2) 
      tt <- t(apply(data[, -1], 1, function(d)z <- t.test(d[cl1], d[cl2]); c(z$estimate, z$p.value)))
      tt[, 1] <- tt[, 1] - tt[, 2]
      tt <- tt[, -2]
      tt <- cbind(symbol=data[, 1], as.data.frame(tt), rank=NA)
      tt[, 3] <- -log(tt[, 3], 10)
      colnames(tt)[2:3] <- c("log.ratio", "neg.log(t.test)")
      tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)
      tt <- tt[order(tt[, 4], decreasing=T), ]
      tt

      Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"


      When I am running function as whole says that



      Error: unexpected '}' in "}"


      When I am putting




      tt= volcan(data,cl1,cl2)




      and doing line by line going down after



      tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)


      Says



      Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"


      I am not sure why, I put comma in



       tt[, 4] <- sqrt(tt[, 2]^4 , tt[, 3]^2)


      But another error










      share|improve this question











      $endgroup$




      I have this matrix of expression data



      > head(data[,1:6])
      Symbol cl1 cl1.1 cl1.2 cl1.3 cl1.4
      1 ACTB 14.07922 14.25211 13.547206 14.046814 15.33551
      2 ATP5F1 10.43386 10.34219 9.671036 9.862641 10.39786
      3 DDX5 13.99250 13.29734 13.706894 13.084000 13.73379
      4 EEF1G 14.35303 14.26112 13.523434 13.327333 13.97747
      5 GAPDH 16.07695 15.61435 15.454911 15.233670 15.90100
      6 NCL 14.35149 13.32919 13.051861 12.704973 13.55680
      >


      I have 24 samples as cl1 and 30 samples as cl2



      I want to do a t.tset, I have this function but I am not sure Why I am getting error by



      volcan <- function(data, cl1, cl2) 
      tt <- t(apply(data[, -1], 1, function(d)z <- t.test(d[cl1], d[cl2]); c(z$estimate, z$p.value)))
      tt[, 1] <- tt[, 1] - tt[, 2]
      tt <- tt[, -2]
      tt <- cbind(symbol=data[, 1], as.data.frame(tt), rank=NA)
      tt[, 3] <- -log(tt[, 3], 10)
      colnames(tt)[2:3] <- c("log.ratio", "neg.log(t.test)")
      tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)
      tt <- tt[order(tt[, 4], decreasing=T), ]
      tt

      Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"


      When I am running function as whole says that



      Error: unexpected '}' in "}"


      When I am putting




      tt= volcan(data,cl1,cl2)




      and doing line by line going down after



      tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)


      Says



      Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"


      I am not sure why, I put comma in



       tt[, 4] <- sqrt(tt[, 2]^4 , tt[, 3]^2)


      But another error







      r rna-seq






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 12 at 18:52







      Feresh Teh

















      asked Jan 12 at 17:54









      Feresh TehFeresh Teh

      33711




      33711




















          1 Answer
          1






          active

          oldest

          votes


















          5












          $begingroup$

          EDIT: I'm editing my answer as I don't have comment privileges and don't wish to add multiple answers.



          Please don't change the entire premise of the question after you get an answer. If you do, retain the original content so the post makes some sense to people.



          Run ?sqrt and check how the function is to be invoked, and how you're invoking it. Does it even accept 2 input parameters?




          Original Content



          You are subsetting the 2D object data improperly. How can data be subset as both data[,1:6] and d[data[,1:24]] where d = data? Fix that and your r code will work OK (syntactically at least).






          share|improve this answer











          $endgroup$












          • $begingroup$
            Sorry, instead how I can define c1l and cl2 classes for first function so I don't have to subset data manually in second function
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:04










          • $begingroup$
            Use grepl on the colnames(d) to pick relevant columns and then subset by the results of the grepl. You should really Google this stuff.
            $endgroup$
            – Ram RS
            Jan 12 at 18:11










          • $begingroup$
            Hang on, in the first case you defined a function with 3 parameters and used just 1. What gives?
            $endgroup$
            – Ram RS
            Jan 12 at 18:13










          • $begingroup$
            Thank you but your comment about grep I could run the function and I edited my post
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:18










          • $begingroup$
            Why am I getting error - the error is pretty explicit. The function is not being invoked properly.
            $endgroup$
            – Ram RS
            Jan 12 at 18:43










          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "676"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbioinformatics.stackexchange.com%2fquestions%2f6800%2fchanging-this-function-to-work%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5












          $begingroup$

          EDIT: I'm editing my answer as I don't have comment privileges and don't wish to add multiple answers.



          Please don't change the entire premise of the question after you get an answer. If you do, retain the original content so the post makes some sense to people.



          Run ?sqrt and check how the function is to be invoked, and how you're invoking it. Does it even accept 2 input parameters?




          Original Content



          You are subsetting the 2D object data improperly. How can data be subset as both data[,1:6] and d[data[,1:24]] where d = data? Fix that and your r code will work OK (syntactically at least).






          share|improve this answer











          $endgroup$












          • $begingroup$
            Sorry, instead how I can define c1l and cl2 classes for first function so I don't have to subset data manually in second function
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:04










          • $begingroup$
            Use grepl on the colnames(d) to pick relevant columns and then subset by the results of the grepl. You should really Google this stuff.
            $endgroup$
            – Ram RS
            Jan 12 at 18:11










          • $begingroup$
            Hang on, in the first case you defined a function with 3 parameters and used just 1. What gives?
            $endgroup$
            – Ram RS
            Jan 12 at 18:13










          • $begingroup$
            Thank you but your comment about grep I could run the function and I edited my post
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:18










          • $begingroup$
            Why am I getting error - the error is pretty explicit. The function is not being invoked properly.
            $endgroup$
            – Ram RS
            Jan 12 at 18:43















          5












          $begingroup$

          EDIT: I'm editing my answer as I don't have comment privileges and don't wish to add multiple answers.



          Please don't change the entire premise of the question after you get an answer. If you do, retain the original content so the post makes some sense to people.



          Run ?sqrt and check how the function is to be invoked, and how you're invoking it. Does it even accept 2 input parameters?




          Original Content



          You are subsetting the 2D object data improperly. How can data be subset as both data[,1:6] and d[data[,1:24]] where d = data? Fix that and your r code will work OK (syntactically at least).






          share|improve this answer











          $endgroup$












          • $begingroup$
            Sorry, instead how I can define c1l and cl2 classes for first function so I don't have to subset data manually in second function
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:04










          • $begingroup$
            Use grepl on the colnames(d) to pick relevant columns and then subset by the results of the grepl. You should really Google this stuff.
            $endgroup$
            – Ram RS
            Jan 12 at 18:11










          • $begingroup$
            Hang on, in the first case you defined a function with 3 parameters and used just 1. What gives?
            $endgroup$
            – Ram RS
            Jan 12 at 18:13










          • $begingroup$
            Thank you but your comment about grep I could run the function and I edited my post
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:18










          • $begingroup$
            Why am I getting error - the error is pretty explicit. The function is not being invoked properly.
            $endgroup$
            – Ram RS
            Jan 12 at 18:43













          5












          5








          5





          $begingroup$

          EDIT: I'm editing my answer as I don't have comment privileges and don't wish to add multiple answers.



          Please don't change the entire premise of the question after you get an answer. If you do, retain the original content so the post makes some sense to people.



          Run ?sqrt and check how the function is to be invoked, and how you're invoking it. Does it even accept 2 input parameters?




          Original Content



          You are subsetting the 2D object data improperly. How can data be subset as both data[,1:6] and d[data[,1:24]] where d = data? Fix that and your r code will work OK (syntactically at least).






          share|improve this answer











          $endgroup$



          EDIT: I'm editing my answer as I don't have comment privileges and don't wish to add multiple answers.



          Please don't change the entire premise of the question after you get an answer. If you do, retain the original content so the post makes some sense to people.



          Run ?sqrt and check how the function is to be invoked, and how you're invoking it. Does it even accept 2 input parameters?




          Original Content



          You are subsetting the 2D object data improperly. How can data be subset as both data[,1:6] and d[data[,1:24]] where d = data? Fix that and your r code will work OK (syntactically at least).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 12 at 18:56

























          answered Jan 12 at 18:00









          Ram RSRam RS

          514




          514











          • $begingroup$
            Sorry, instead how I can define c1l and cl2 classes for first function so I don't have to subset data manually in second function
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:04










          • $begingroup$
            Use grepl on the colnames(d) to pick relevant columns and then subset by the results of the grepl. You should really Google this stuff.
            $endgroup$
            – Ram RS
            Jan 12 at 18:11










          • $begingroup$
            Hang on, in the first case you defined a function with 3 parameters and used just 1. What gives?
            $endgroup$
            – Ram RS
            Jan 12 at 18:13










          • $begingroup$
            Thank you but your comment about grep I could run the function and I edited my post
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:18










          • $begingroup$
            Why am I getting error - the error is pretty explicit. The function is not being invoked properly.
            $endgroup$
            – Ram RS
            Jan 12 at 18:43
















          • $begingroup$
            Sorry, instead how I can define c1l and cl2 classes for first function so I don't have to subset data manually in second function
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:04










          • $begingroup$
            Use grepl on the colnames(d) to pick relevant columns and then subset by the results of the grepl. You should really Google this stuff.
            $endgroup$
            – Ram RS
            Jan 12 at 18:11










          • $begingroup$
            Hang on, in the first case you defined a function with 3 parameters and used just 1. What gives?
            $endgroup$
            – Ram RS
            Jan 12 at 18:13










          • $begingroup$
            Thank you but your comment about grep I could run the function and I edited my post
            $endgroup$
            – Feresh Teh
            Jan 12 at 18:18










          • $begingroup$
            Why am I getting error - the error is pretty explicit. The function is not being invoked properly.
            $endgroup$
            – Ram RS
            Jan 12 at 18:43















          $begingroup$
          Sorry, instead how I can define c1l and cl2 classes for first function so I don't have to subset data manually in second function
          $endgroup$
          – Feresh Teh
          Jan 12 at 18:04




          $begingroup$
          Sorry, instead how I can define c1l and cl2 classes for first function so I don't have to subset data manually in second function
          $endgroup$
          – Feresh Teh
          Jan 12 at 18:04












          $begingroup$
          Use grepl on the colnames(d) to pick relevant columns and then subset by the results of the grepl. You should really Google this stuff.
          $endgroup$
          – Ram RS
          Jan 12 at 18:11




          $begingroup$
          Use grepl on the colnames(d) to pick relevant columns and then subset by the results of the grepl. You should really Google this stuff.
          $endgroup$
          – Ram RS
          Jan 12 at 18:11












          $begingroup$
          Hang on, in the first case you defined a function with 3 parameters and used just 1. What gives?
          $endgroup$
          – Ram RS
          Jan 12 at 18:13




          $begingroup$
          Hang on, in the first case you defined a function with 3 parameters and used just 1. What gives?
          $endgroup$
          – Ram RS
          Jan 12 at 18:13












          $begingroup$
          Thank you but your comment about grep I could run the function and I edited my post
          $endgroup$
          – Feresh Teh
          Jan 12 at 18:18




          $begingroup$
          Thank you but your comment about grep I could run the function and I edited my post
          $endgroup$
          – Feresh Teh
          Jan 12 at 18:18












          $begingroup$
          Why am I getting error - the error is pretty explicit. The function is not being invoked properly.
          $endgroup$
          – Ram RS
          Jan 12 at 18:43




          $begingroup$
          Why am I getting error - the error is pretty explicit. The function is not being invoked properly.
          $endgroup$
          – Ram RS
          Jan 12 at 18:43

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Bioinformatics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbioinformatics.stackexchange.com%2fquestions%2f6800%2fchanging-this-function-to-work%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay