Drupal 7 how can I alter page content generated with module? I have one module:

function MYMODULE_menu() {
    $items = array();
    $items['mymodule'] = array(
      'title' =&gt; t('My Module'),
      'page callback' =&gt; 'MYMODULE_view',
      'access arguments' =&gt; array('access content'),
      'page arguments' =&gt; array(1),
      'type' =&gt; MENU_NORMAL_ITEM,
    );

    return $items;
}
function MYMODULE_view() {
   return array(
        '#theme' =&gt; 'my_module_theme',
        '#variable' =&gt; 'some variable'
    );
}


In the other module I want to alter this content to change the theme and add some variables. How can I do it?
You can change the variables of the page content implementing the template_preprocess_page() function in your module or theme. As of Clive's comment, I want to update that you can preferably use hook_page_alter(), which is called earlier than preprocess function.

function YOURMODULE_preprocess_page(&amp;$variables) {
  // Do your changes here
  // If have Devel module installed
  // You can use dpm() function to print the contents of $variables array. 
  // dpm($variables)
}


or

function YOURMODULE_page_alter(&amp;$page) {
  // Do your changes here
  // If have Devel module installed
  // You can use dpm() function to print the contents of $variables array. 
  // dpm($page)
}


Additional Reference:


Render Arrays in Drupal 7 See the section "Creating Content As Render Array"



  A page callback should return a render array, as should hook_block_view()'s $block['content']. This allows your module and other modules to treat the content as data for as long as possible in the page generation process.